How to freeze map while dragging a graphic?

3152
2
Jump to solution
07-10-2015 05:57 PM
by Anonymous User
Not applicable

Hi All

I'm looking for a way to click on a graphic/icon and drag it around the screen. I have been successful with the following method:

Currently, the code fires inside the onPressAndHold handler and checks to see if a graphic is under the mouseclick/point touched, if yes then it grabs the id of that graphic, and uses in in the onPositionChanged handler to bind the graphic's x,y to the mouse x,y and therefore successfully moves the graphic around until the mouse is released.

My issue is that the onPressAndHold takes a bit long to fire for my liking - my users would be doing this a lot and I think that waiting that extra second each time would soon get annoying.

the onPressAndHold seems to automatically freeze the map while you move the mouse around, but I couldn't find any property of the Map object that explicitly locks or freezes the panning - if there was one then I could use it inside the onPressed handler to temporarily disable the map panning.

Does anyone have any ideas on how I might achieve this using the onPressed instead of onPressAndHold?

Thanks

-Paul

0 Kudos
1 Solution

Accepted Solutions
ShobanaSuresh
Esri Contributor

Hi Paul,

To disable map's default pan behavior, mouse.accepted property has to be to set to true in onMousePositionChanged handler.  Accepting the mouse event will disable the event propagation.

```

onMousePositionChanged: {

   mouse.accepted = true;

}

```

View solution in original post

0 Kudos
2 Replies
ShobanaSuresh
Esri Contributor

Hi Paul,

To disable map's default pan behavior, mouse.accepted property has to be to set to true in onMousePositionChanged handler.  Accepting the mouse event will disable the event propagation.

```

onMousePositionChanged: {

   mouse.accepted = true;

}

```

0 Kudos
by Anonymous User
Not applicable

Hi Shobana

Thanks for that! Using 'mouse.accepted = true' I've been able to implement the action I needed.

Cheers,

-Paul

0 Kudos