Select to view content in your preferred language

Migrating from Google Maps

643
3
10-25-2021 10:29 PM
KamilSindi
New Contributor

Hello community!

We are migrating our Google Maps based web application over to Esri. Our application shows locations updating on the screen.

With google maps you can use the setPosition method on a marker to move the marker position. I have not found something similar within Esri. Would I have to clear my graphic and create a new one in place of it? I'm trying to think of a way to show several different locations updating without having to redraw each graphic.

Any help is appreciated!

0 Kudos
3 Replies
ReneRubalcava
Honored Contributor

You can update the geometry of the graphic directly like in this demo.

https://codepen.io/odoe/pen/NWvjbKo?editors=0010

view.on("click", ({ mapPoint }) => {
	graphic.geometry = mapPoint;
});
0 Kudos
JohnGrayson
Esri Regular Contributor

Are you using a GraphicsLayer, or a FeatureLayer defined with client-side Graphics?  Here's a simple CodePen that shows how to apply client-side updates to either one:

https://codepen.io/john-grayson/pen/oNeWLqr

 

0 Kudos
shaylavi
Esri Contributor

There are huge huge differences in terms of how Google maps works compared to ESRI and if you're searching a direct "translation" of the functionality you had in Google into ESRI then you're looking at it wrong. Just like you can't translate every sentence directly from one language to another (might not be the best analogy).

If you'd like to achieve the functionality of dragging a point over the map to update it's location, you need to understand the fundamentals of ESRI and how to publish editable layers, which then gives you this functionality out-of-the-box. The answers you received here are just workarounds to try and mimic that behaviour based on what you already know from Google, which is very wrong in my opinion. A new product requires a new approach and different (better) solutions.

Shay
0 Kudos