View "drag" and "dragend" event?

1794
1
02-15-2019 08:42 AM
MiroslavMatovic
New Contributor II

I am using ArcGIS API for JavaScript 4.10 and I want to implement a dragging of map view that will have a location pin (point graphic) in the center of the view. I have handled "drag" event of the view and used lat/long coordinates in view.extent.center like this :

view.on("drag", function(evt) {
var locationGraphic = getCurrentLocationGraphics();
view.graphics.removeMany(locationGraphic);
view.graphics.add(new Graphic(new Point([view.extent.center.longitude,view.extent.center.latitude]), selectedLocation));
});

However, I can't handle setting of these coordinates when the dragging of the view ends. I want to set some values and trigger functions when dragging stops. How can I accomplish this?

0 Kudos
1 Reply
TorbenKraft
New Contributor

Hi Miroslav Matovic,

if you want to trigger actions in the drag event in version 4.10 you can check the event attributes for 'action'.

You can add this inside your on.drag function.

if (evt.action === 'start')

if (evt.action === 'update')

if (evt.action === 'end')

With these conditions you can trigger actions, when the drag startet, the dragging lasts or at the end of the dragging.

I hope this will help you and answers your questions.

0 Kudos