Good day to all, I add a point to the map, after clicking on the location button, this label should be removed and added elsewhere on the map with different coordinates, below is the code

mainPoint = new Point(geoPosition.getLatitude(), geoPosition.getLongitude()); mapView.getMap().move( new CameraPosition(mainPoint, 15.0f, 0.0f, 0.0f), new Animation(Animation.Type.SMOOTH, 0), null); mapView.getMap().getMapObjects().addPlacemark(mainPoint,ImageProvider.fromResource(this, R.drawable.mygeo_light_icon)); 

so I add a label to the map, it works. Then I try to remove it from the map and add a new one with updated coordinates.

 mapView.getMap().getMapObjects().remove((MapObject) mainPoint); mainPoint = new Point(geoPosition.getLatitude(), geoPosition.getLongitude()); 

There are two questions:

  1. Is it possible not to delete the label and just move it with new ones?
    coordinates?
  2. If the first item disappears, then how to remove a specific label? In my version does not work due to the fact that Point is impossible
    convert to MapObject

    1 answer 1

    You can move a point object, of course. It is enough to save the result of the addPlacemark call and call its setGeometry method: https://tech.yandex.ru/mapkit/doc/3.x/concepts/android/mapkit/ref/com/yandex/mapkit/map/PlacemarkMapObject-docpage/ #method_detail__method_setGeometry__Point