How to move points on map?

I tried to move points on GeoMap programmatically and got no effect.
With something like this:
point.getGeometry().getCoordinate().setCoordinate(new CoordinateXY(x,y));
How to do it right? Is it possible?

Hi, @evgenypopov

Although JTS geometry classes are mutable, it’s not a good practice to change their coordinates programmatically (as explained here).
The better way is to replace geometry instances with the new ones, for example:

import com.haulmont.addon.maps.gis.utils.GeometryUtils;

...

Point point = GeometryUtils.createPoint(50, 50);
address.setLocation(point);

In case of using the Canvas layer, the only possible way now is to remove the old point and add the new one. Perhaps it would be useful to have a method setGeometry(Point point) on the CanvasLayer.Point to update the geometry, we will think about adding it to the add-on.

Regards,
Gleb

1 Like