How to make graphic not moving when zoom the map?

888
6
08-09-2021 08:40 PM
howard
by
New Contributor II

Hi,

I have a question, I use SketchViewModel to draw the shape on map, I want to keep the shape located in center (not moving) when the zoom in/out the map; how can I implement it?  

Thanks in advance.

0 Kudos
6 Replies
LefterisKoumis
Occasional Contributor III

Use the center of the screen as the coordinates of your graphic.

var x = window.innerWidth / 2;
var y = window.innerHeight / 2;
0 Kudos
howard
by
New Contributor II

Thanks LefterisKoumis.

If the shape is not in center, how make the shape looks like keeping statis position and size?

0 Kudos
CourtneyMenikheim
Occasional Contributor

This question is answered on this thread: https://community.esri.com/t5/arcgis-api-for-javascript-questions/how-to-make-graphic-not-moving-whe...
(In case anyone else stumbles along looking for an answer)

Courtney Menikheim | Application Developer | @thecmenikheim
0 Kudos
howard
by
New Contributor II

Hi CourtneyMenikheim

Your mentioned thread is keeping the shape not moved when moving the map; but how to keep the shape not scale and move (size and position looks like unchange in screen) when zooming the map; adjust the coordinates of shape seems that cannot get the desired effect.

Could you give some helps, thanks!

Thanks.

0 Kudos
CourtneyMenikheim
Occasional Contributor

To clarify, you want the shape:
- to be on the map
- to stay on the screen in the same spot, even as the user pans the map
- to stay the same size, even as the user zooms in and out

Is that correct?

Courtney Menikheim | Application Developer | @thecmenikheim
0 Kudos
howard
by
New Contributor II

Yes, that is correct!

Thanks!

0 Kudos