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

Conditional context menu for markers on map

3 Answers 181 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Veteran
Jason asked on 09 Sep 2020, 05:54 PM

I am adding markers for a few types of things.  Is it possible to add a context menu on only certain ones.

 

I have markers for orders and markers for orders in loads which are joined by lines.

 

I need to be able to have a context menu for the orders that are in a load to be able to remove the order from the load.

3 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
Veteran
answered on 09 Sep 2020, 05:58 PM
Also, how would I pass the marker into a method to call based on the context menu.
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 11 Sep 2020, 03:42 PM

Hello, Jason,

To conditionally show the Kendo UI ContextMenu over some markers, you could add a class to the elements that you wish to target. For example, you may use the markerActivate event:

 markerActivate: function(e) {
              if(e.marker.options.tooltip.content == "Austin, TX"){
                e.marker.element.addClass("foo");
              }
            },

Then you may set that class as the ContextMenu target. Finally, the select event of the ContextMenu will provide you the marker element and you can obtain the marker from it as demonstrated below:

 var myContextMenu = $("#my-menu").kendoContextMenu({
            target: ".k-marker.foo",
            select: function(e){
              console.log($(e.target).data("kendoMarker"))
            }
 }).data("kendoContextMenu");

http://dojo.telerik.com/EjEQupuv/2

Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Jason
Top achievements
Rank 1
Veteran
answered on 11 Sep 2020, 05:24 PM
This worked great.  Thanks
Tags
Map
Asked by
Jason
Top achievements
Rank 1
Veteran
Answers by
Jason
Top achievements
Rank 1
Veteran
Alex Hajigeorgieva
Telerik team
Share this question
or