Skip to content

Instantly share code, notes, and snippets.

@zogreptile
Created April 19, 2018 07:09
Show Gist options
  • Save zogreptile/a5d14c3b9a72322ee1f10df0d4ca9237 to your computer and use it in GitHub Desktop.
Save zogreptile/a5d14c3b9a72322ee1f10df0d4ca9237 to your computer and use it in GitHub Desktop.
Метка на яндекс карте по геокодеру.
ymaps.ready(function () {
var geocoder = ymaps.geocode("{{ object_item.address }}", {result: 1});
geocoder.then(
function (res) {
var point = res.geoObjects.get(0),
mapCenter = point.geometry.getCoordinates();
var map = new ymaps.Map('map', {
center: mapCenter,
zoom: 17
});
ymaps.geoQuery(ymaps.geocode("{{ object_item.address }}")).addToMap(map);
},
function (err) {
console.log("Yandex map geocoder error!");
console.log(err);
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment