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 Answer 1

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);
        }
    });
1
  • in my case userLocationLayer.cameraPosition() returns null
    – Ivan
    Mar 31, 2022 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.