Completed
Last Updated: 09 Jun 2021 14:23 by ADMIN
Release R2 2021 SP1
Ketan
Created on: 28 May 2021 06:50
Category: Map
Type: Bug Report
0
RadMap: Exception while adding MapPin to a MapLayer (which is not added to RadMap)

Hi,

Please refer attached screen.

In a specific use case, it was required to add MapPins to a MapLayer, and later MapLayer to be added to a RadMap, and this exception.

Thanks

Attached Files:
1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 28 May 2021 08:41
Hello, Ketan,

Indeed, when you add a MapPin to a MapLayer that is not added to the map yet, a NullReferenceException occurs:    
        public RadForm1()
        {
            InitializeComponent();

            OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
            osmProvider.EnableCaching = false;
            MapTileDownloader tileDownloader = osmProvider.TileDownloader as MapTileDownloader;
            tileDownloader.WebHeaders.Add(System.Net.HttpRequestHeader.UserAgent, "your application name");
            this.radMap1.MapElement.Providers.Add(osmProvider);

            var layer1 = new MapLayer();
            MapPin pin = new MapPin(new PointG(34.04302, -118.26725));
            layer1.Add(pin);

            this.radMap1.Layers.Add(layer1);

        }

I am logging it in our feedback portal by converting this ticket into a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to add the layer to the map first and then add the pins.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.