Answer the question
In order to leave comments, you need to log in
Yandex map is not displayed?
Hello, please tell me why the map is not displayed
<div id="map" style="width:400px; height:300px"></div>
<script src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>
<script type="text/javascript"><![CDATA[
var myMap;
// Дождёмся загрузки API и готовности DOM.
document.addEventListener("DOMContentLoaded", function(){
ymaps.ready(init);
});
function init () {
// Создание экземпляра карты и его привязка к контейнеру с
// заданным id ("map").
var offices = "[{"title":"Отделение №314", "timetable":"вт.—сб.: 10:00—19:00", "address":"Тюменская обл., г. Заводоуковск, улица Первомайская, д. 9 Б", "mapx":"56.5096317447426", "mapy":"66.537086186508"},{"title":"Отделение №143", "timetable":"пн.—пт.: 09:00—18:00", "address":"Тюменская обл., г. Заводоуковск, улица Шоссейная, д. 156", "mapx":"56.515616517064", "mapy":"66.5157428981474"}]";
if(offices == 0){
console.log('offices = 0', document.getElementById("mapOffices"));
document.getElementById("mapOffices").style.display = "none";
return;
}
var dots = JSON.parse(offices);
myMap = new ymaps.Map('map', {
center: [dots[0].mapx, dots[0].mapy],
zoom: 12
});
myMap.behaviors.disable('scrollZoom');
myMap.controls.remove('searchControl');
myMap.controls.remove('typeSelector');
myMap.controls.remove('geolocationControl');
var geolocationControl = new ymaps.control.GeolocationControl({
data: {
content: "Рядом со мной",
title: "Показать отделения и банкоматы рядом с Вами"
},
options: {noPlacemark: false, maxWidth: 150}
});
myMap.controls.add(geolocationControl);
var myGeoObjects = [];
for(var i in dots){
myGeoObjects[i] = new ymaps.GeoObject({
geometry: {
type: "Point",
coordinates: [dots[i].mapx, dots[i].mapy]
},
properties: {
clusterCaption: dots[i].title,
balloonContentBody: 'Адрес: '+dots[i].address+'<br/>Режим работы:<br/>'+dots[i].timetable
}
});
}
var myClusterer = new ymaps.Clusterer({clusterDisableClickZoom: true});
myClusterer.add(myGeoObjects);
myMap.geoObjects.add(myClusterer);
}
]]></script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question