V
V
Vadim Popov2018-06-26 16:59:36
Java
Vadim Popov, 2018-06-26 16:59:36

How to delete a specific Point in the yandex map kit 3.0 library?

Good afternoon everyone, I add a label (point) to the map, after clicking on the location button, this label should be removed and added in another place 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, everything 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, but simply move it with new coordinates?
2. If the first item is missing, then how to remove a specific label? In my version, it does not work due to the fact that Point cannot be converted to MapObject

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-06-26
@vadimpopov94

the addPlacemark method returns a PlacemarkMapObject, you need to remember it. It can be removed, and you can also change the position (setGeometry).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question