A
A
a_donov2017-08-29 17:19:52
Yandex maps
a_donov, 2017-08-29 17:19:52

How to change the zoom after finding the location?

Good afternoon.
I determine the geolocation through the browser in the following way:

$button.check_location.click(function() {
    ymaps.geolocation.get({
        provider: 'browser',
        mapStateAutoApply: true
    }).then(function (result) {
        result.geoObjects.options.set('preset', 'islands#redCircleIcon');
        ymap.geoObjects.add(result.geoObjects);
    });
});

After determining the location, you need to change the zoom of the map.
Googling, I found a working code:
ymap.setCenter({result.geoObjects.get(0).geometry.getCoordinates(), 14, {duration: 300}});

but its implementation removes the label from the map.
How to combine them to keep the mark and change the zoom?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
call007, 2021-03-08
@call007

how it should have been

ymap.setCenter(result.geoObjects.get(0).geometry.getCoordinates(), 14, {duration: 300});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question