How can I detect shapeClick events for shapes not in the top layer?

1 Answer 25 Views
Map
Tom
Top achievements
Rank 1
Tom asked on 21 Jan 2022, 09:50 PM

I'm using the RadMap to show states of the USA.

layers[0] is Bing.
layers[1] contains a shape for every US state/territory.
layers[2-53] contain the counties (subdivisions) for each state/territory.

When the user clicks a state, I handle the shapeClick event to .show() the corresponding layer for the state's counties. This works fine.

Once layer 2 - 53 is shown, however, the shapeClick no longer fires when a shape in layer 1 is clicked, presumably because it is no longer "on top" and shapeClick is only fired for layer x. Is there a way to receive shapeClick events no matter which layer is "on top"?

If not, is there a way to get the data from the map's regular Click event and somehow use that to determine the shape that covers it in layer 1?

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 26 Jan 2022, 04:10 PM

Hello Tom,

RadMap does not provide a layer-merging functionality at the moment thus its events are triggered only for the top most layer.

Nevertheless, you can try the approach suggested in the following thread and see if disabling the mouse events for all layers above the first one would be applicable to your needs:

https://www.telerik.com/forums/shapemouseenter-event-on-map-with-multiple-geojson-layers

Regards,
Vessy
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/.

Tom
Top achievements
Rank 1
commented on 26 Jan 2022, 04:32 PM

Thank you, Vessy.

Unfortunately, I need the events to continue firing for the top layer. The link suggests loading everything into a single layer, which I would be willing to do. However, that would require me to .show() or .hide() specific shapes within the layer, which I don't think is possible, either. Or is it?

Alternatively, would there be some sort of hack to take the information from the map.click event (which always fires) and trigger the shapeClick event somehow? Or could you direct me to the object on the map that would let me write my own algorithm to determine which shape the map.click occurred within?

Thanks for your help!

Vessy
Telerik team
commented on 31 Jan 2022, 01:45 PM

Hi Tom,

I am afraid that there is no any suitable event or object that I can suggest you for the moment. If you wish, you can submit a feature request for triggering the shapeClick event for all layers directly in the Kendo UI Feedback portal:

https://feedback.telerik.com/kendo-jquery-ui?listMode=Recent&typeId=2&categoryId=1311

Once this functionality is implemented in Kendo, it will be inherited by RadMap as well.

Tom
Top achievements
Rank 1
commented on 31 Jan 2022, 04:43 PM

What about the other approaches I mentioned. Do you think any of them are possible?
Vessy
Telerik team
commented on 03 Feb 2022, 03:18 PM

Hi Tom,

I am afraid that neither one of the mentioned approaches cannot be achieved at the moment. A possible option you can consider is to bind a transparent copy of the first layer at the top and handle its events.

Tags
Map
Asked by
Tom
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or