Answer the question
In order to leave comments, you need to log in
How to resolve the setCenter conflict in Yandex?
Good afternoon!
The error is as follows.
When creating a map, I use this code (automatic detection of the city on the map):
function init() {
var geolocation = ymaps.geolocation,
myMap = new ymaps.Map('map', {
center: [55, 34],
zoom: 10
}, {
searchControlProvider: 'yandex#search'
});
geolocation.get({
provider: 'yandex',
mapStateAutoApply: true
}).then(function (result) {
result.geoObjects.options.set('preset', 'islands#redCircleIcon');
result.geoObjects.get(0).properties.set({
balloonContentBody: 'Мое местоположение'
});
myMap.geoObjects.add(result.geoObjects);
});
geolocation.get({
provider: 'browser',
mapStateAutoApply: true
}).then(function (result) {
result.geoObjects.options.set('preset', 'islands#blueCircleIcon');
myMap.geoObjects.add(result.geoObjects);
});
function ChangeMap () {
myMap.setCenter([58.010450, 56.229434]);
}
Answer the question
In order to leave comments, you need to log in
At first glance, the code is ok, it should work
And the center of the map does not find
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question