AnsweredAssumed Answered

Update graphic geometry on 4.0

Question asked by david.meza on May 13, 2016
Latest reply on Apr 12, 2017 by TSolow-esristaff


In the previous API version I was able to update the geometry of a graphic using the setter (e.g. myGraphic.setGeometry(new Point([lon, lat])) ). In the current version, this functionality has been replaced by watchers/observers, but it seems this is missing on graphics. I've tried:

 

myGraphic.geometry = new Point([lon, lat])); // The obvious one

// And all these other ones...
myGraphic.geometry.update(lon,lat);
myGraphic.geometry.latitude = lat;
myGraphic.geometry.longitude = lon;
myGraphic.geometry.setLatitude(lat);
myGraphic.geometry.setLongitude(lon);
// Same methods using x and y, etc...

 

This will work if you haven't added the graphic to the map / graphicsLayer, but once you do so it is stuck at that position, no matter what method you use to update the geometry. In the meantime, I've implemented a workaround where I remove the old graphic and add a new one with the new geometry, but this is not desirable since it causes a momentary flash on the screen where there are no graphics. 

Outcomes