clubmen
Профессор
- Регистрация
- 18 Янв 2010
- Сообщения
- 222
- Реакции
- 49
- Автор темы
- #1
Лог ошибки:
сам код:
Подскажите как побороть данную ошибку
Код:
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.main.js:57 almain.js:58 (anonymous function)js?sensor=true®ion=nz&async=2&callback=MapApiLoaded&_=1423392865179:21 google.maps.Loadmain.js:58 (anonymous function)main.js:59 (anonymous function)
сам код:
Код:
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(56.323297, 43.062578);
var mapOptions = {
zoom: 15,
center: myLatlng,
scaleControl: true
};
var allMarkers = [],
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions),
markers = {new_obj},
infoWin = [],
setMarker = function (markers, clear) {
if (clear) {
for (var i in allMarkers) {
allMarkers[i].setMap(null)
}
}
for (var i in infoWin) {
console.log(infoWin[i])
infoWin[i].close();
}
for (var i in markers) {
var marker = null;
if (typeof allMarkers[markers[i].id] == 'object') {
marker = allMarkers[markers[i].id];
allMarkers[i].setMap(map);
} else {
var prepareCords = markers[i].LatLng.split(',');
var icon = (markers[i].icon) ? new google.maps.MarkerImage(markers[i].icon) : null;
console.log(markers[i].icon,icon);
marker = new google.maps.Marker({
id: markers[i].id,
position: new google.maps.LatLng(prepareCords[0], prepareCords[1]),
map: map,
icon: icon,
clickable: true,
title: markers[i].title,
contentString: markers[i].contentString
});
google.maps.event.addDomListener(marker, 'click', function (e) {
for (var j in infoWin) {
infoWin[j].close();
}
infoWin[this.id] = new google.maps.InfoWindow({
content: this.contentString,
maxWidth: 200
});
infoWin[this.id].open(map, this)
});
allMarkers[markers[i].id] = marker;
}
}
}
for (var i in markers) {
setMarker(markers[i], false)
}
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
$('*[data-cat]').click(function () {
var id = $(this).data('cat');
if (id == 0) {
for (var i in markers) {
setMarker(markers[i], false)
}
} else {
setMarker(markers[id], true)
}
})
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Подскажите как побороть данную ошибку