Events on the edge of the shapes are not invoking

Nilesh Khonde 60 Reputation points
2024-10-18T10:49:06.6733333+00:00

Hi, I am using the Azure Maps Drawing Tool module. Here is the link for it

https://samples.azuremaps.com/?search=Drawing%20Tools&sample=change-drawing-rendering-style

I am facing an issue related to drawing layers on the map. For example, I have drawn two shapes on the map, and I am trying to edit those shapes using some custom code. I have also added some alerts on those layers to check whether the events are working correctly.


  // Wait until the map resources are ready.
    map.events.add("ready", function () {
      // Create an instance of the drawing manager and display the drawing toolbar.
      drawingManager = new atlas.drawing.DrawingManager(map, {
        // toolbar: new atlas.control.DrawingToolbar({}),
      });
      var drawingLayers = drawingManager.getLayers();

      map.events.add("click", drawingLayers.polygonLayer, (e) => {
        alert("Polygon clicked");
      });
      map.events.add("click", drawingLayers.polygonOutlineLayer, (e) => {
        alert("Polygon Outline clicked");
      });
      map.events.add("click", drawingLayers.lineLayer, (e) => {
        alert("Line clicked");
      });
      map.events.add("click", drawingLayers.pointLayer, (e) => {
        alert("Point clicked");
      });
      // Event listener for shape click
      map.events.add("click", getShapeClicked,(e) => {
        alert("Shape clicked");
      });
    });


But issue is whenever I click within the shape event trigger finely.

Screenshot (75)Screenshot (74)

Screenshot (76)

But when I try to edit the shape and click on the edges of the drawn shape, my shapes enter edit mode, but no event is invoked.

As per my understanding, on click of edge of the shape while edit mode is selected, it should trigger the polygonOutlineLayer event, because many of my other functionalities depend on this. This event helps determine which shape is selected on the map.

Also, when I hover over the edge of the shape, the mouse cursor changes to a hand. Is there a way I can restrict this or change it to a different cursor style?

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
734 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. rbrundritt 18,671 Reputation points Microsoft Employee
    2024-10-21T16:25:29.2666667+00:00

    When in edit mode shapes use a separate set of layers for rendering. These are the preview layers. You can get these like this: var previewLayers = drawingManager.getPreviewLayers() You can then add events to these as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.