0
지도 및 마커를 표시하는 위치 페이지가있는 사용자 지정 WordPress 사이트를 상속 받았습니다. 다른 위치에서 해당 페이지의 복사본을 만들려고합니다.2 개의 다른 페이지에 2 개의 google지도를 표시하는 방법?
내 문제는 내 두 번째지도가 전혀 표시되지 않는다는 것입니다. 두 번째지도를 첫 번째 페이지에 배치하면 두지도가 올바르게 표시되기 때문에 다른 페이지에서만지도를로드하지 못하고, 이슈가 뭐야? 여기
는 코드function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 13,
center: cityliving,
panControl: false,
zoomControl: true,
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
draggable: true
}
var mapOptions2 = {
zoom: 13,
center: bishopsgate,
panControl: false,
zoomControl: true,
scrollwheel: false,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
draggable: true
}
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
map2 = new google.maps.Map(document.getElementById('map_canvas2'), mapOptions2);
directionsDisplay.setMap(map);
directionsDisplay.setMap(map2);
var image = '<?php bloginfo('
template_directory ');?>/img/dot.png';
marker = new google.maps.Marker({
position: cityliving,
title: "City Living London",
icon: image
});
marker2 = new google.maps.Marker({
position: bishopsgate,
title: "City Living London",
icon: image
});
var contentString = '<div id="content">' +
'<div id="siteNotice">' +
'</div>' +
'<h1><img src="<?php bloginfo('
template_directory ');?>/img/cityliving.svg" height="50px"></h1>' +
'<div id="bodyContent">' +
'<p>21 Bowling Green Lane <br>London EC1R 0BD</p>' +
'</div>' +
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
google.maps.event.addListener(marker2, 'click', function() {
infowindow.open(map2, marker2);
});
marker.setMap(map);
marker2.setMap(map2);
calculateDistances();
}
google.maps.event.addDomListener(window, 'load', initialize);
// 편집
난 당신이 다른 스크립트를 다른 페이지에 자바 스크립트 오류의 원인이 있다고 생각
확인했는데 두 가지 모두에 어려움을 겪고 있습니다. 위의 스크린 샷을 포함했지만 마지막 줄에 "map = new google.maps.Map (document.getElementById (' map_canvas '), mapOptions); " – Sai