Answer the question
In order to leave comments, you need to log in
How to center a Yandex map using coordinates from a geolocator?
Tell me how, having received an object through the geolocator, I can take the coordinates for the center of the map itself. Suppose a request to a geolocator returns:
["metaDataProperty"]=>
array(1) {
["GeocoderMetaData"]=>
array(5) {
["kind"]=>
string(5) "house"
["text"]=>
string(117) "Россия, Свердловская область, Екатеринбург, улица Белинского, 222"
["precision"]=>
string(5) "exact"
["AddressDetails"]=>
array(1) {
["Country"]=>
array(4) {
["AddressLine"]=>
string(103) "Свердловская область, Екатеринбург, улица Белинского, 222"
["CountryNameCode"]=>
string(2) "RU"
["CountryName"]=>
string(12) "Россия"
["AdministrativeArea"]=>
array(2) {
["AdministrativeAreaName"]=>
string(39) "Свердловская область"
["SubAdministrativeArea"]=>
array(2) {
["SubAdministrativeAreaName"]=>
string(85) "муниципальное образование Город Екатеринбург"
["Locality"]=>
array(2) {
["LocalityName"]=>
string(24) "Екатеринбург"
["Thoroughfare"]=>
array(2) {
["ThoroughfareName"]=>
string(31) "улица Белинского"
["Premise"]=>
array(1) {
["PremiseNumber"]=>
string(3) "222"
}
}
}
}
}
}
}
["id"]=>
string(8) "56068469"
}
}
["description"]=>
string(79) "Екатеринбург, Свердловская область, Россия"
["name"]=>
string(36) "улица Белинского, 222"
["boundedBy"]=>
array(1) {
["Envelope"]=>
array(2) {
["lowerCorner"]=>
string(19) "60.625394 56.797763"
["upperCorner"]=>
string(19) "60.633605 56.802268"
}
}
["Point"]=>
array(1) {
["pos"]=>
string(19) "60.629499 56.800015"
}
}
ymaps.ready(function () {
var myMap = new ymaps.Map("myMap", {
center: 60.629499,56.800015,
zoom: 10,
controls: []
});
});
Answer the question
In order to leave comments, you need to log in
Problem solved. Yandex geolocator gives the result in one format, but it needs to be entered on the map in another. Therefore, you need to swap the latitude and longitude and everything will work correctly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question