This is a migrated thread and some comments may be shown as answers.

Issue with refreshing a map with context menu

1 Answer 313 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Veteran
Jason asked on 18 Sep 2020, 12:48 AM

I have a map where I have markers that are shipments (individual markers) and loads which are a collection of markers joined by lines.  I can right click on a marker that is part of a load and get a menu with the option to remove shipment from load.  In the mode for the remove shipment from the load I am accessing the map layers.  In the removal process, I have to rebuild the map items. I rebuild the map layers by getting the datasource of the necessary layer, setting the data for the datasource to an empty array ([]) and then pushing in the new data to the datasource.

 

I have 2 shape layers and 1 marker layer.

The first time I right click and remove a shipment from a load it works perfectly.  I try it again ( the context menu shows and goes into the called function) and get the following error:

TypeError: Cannot read property 'layer' of undefined

In the called function,

e.target = span.k-marker.k-marker-pinpink.removeFromShipmentContextMenu

$(e.target) finds the element

But $(e.target).data("kendoMarker") returns undefined.

 

What am I missing in reload of the map objects?

 

Thanks

Jason

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 21 Sep 2020, 04:48 PM

Hi, Jason,

I would suggest you use the Marker Layer API for adding, removing and setting a new data source instead of the current workflow to ensure the layer is aware of any changes:

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Map
Asked by
Jason
Top achievements
Rank 1
Veteran
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or