3

How i can build right button on last version of Yandex mapkit? Zoom and location button. I just create map class and confused. The documentation is very meager..

1 Answers1

5
//Your location. Point class
//for example: Point(53.0101, 53.0101);
private Point DRIVER_POSITION = new Point(float, float);
....
userLocationLayer = mapView.getMap().getUserLocationLayer();
    userLocationLayer.setEnabled(true);
    userLocationLayer.setHeadingEnabled(true);
    userLocationLayer.setObjectListener(this);
.....
//onClick events. FAB Button's
.....
    zoomUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapView.getMap().move(new CameraPosition(mapView.getMap().getCameraPosition().getTarget(),
                    mapView.getMap().getCameraPosition().getZoom()+1, 0.0f, 0.0f),
                    new Animation(Animation.Type.SMOOTH, 1),
                    null);
        }
    });
    zoomDown.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapView.getMap().move(new CameraPosition(mapView.getMap().getCameraPosition().getTarget(),
                    mapView.getMap().getCameraPosition().getZoom()-1, 0.0f, 0.0f),
                    new Animation(Animation.Type.SMOOTH, 1),
                    null);
        }
    });
    positionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mapView.getMap().move(
                    new CameraPosition(userLocationLayer.cameraPosition().getTarget(), 15.0f, 0.0f, 0.0f),
                    new Animation(Animation.Type.SMOOTH, 1),
                    null);
        }
    });
AlexS
  • 918
  • 1
  • 12
  • 28