특정 위치에 대한 간단한 Google지도를 렌더링하는 페이지가 있습니다. 이 맵은 localhost에서 로컬로 실행할 때 전혀 문제없이 렌더링되지만 라이브 웹 서버에이 코드를 배포하면 (해당 도메인에 대한 LIVE google API 키 사용) 렌더링이 실패하고 시리즈를 만들 때 페이지의 javascript에 경고가 표시되면 'onLoad body'내에서 호출되어야하는 'Initialize'메소드가 호출되지 않는 것처럼 보입니다.Google지도는 로컬로 렌더링되지만 실제 환경에는 표시되지 않습니다.
라이브 서버에서 렌더링되는 HTML 소스를 볼 때 다른지도 API 키가 있음에도 불구하고 본문 onLoad 이벤트 내 initialize() 호출을 포함하여 사이트의 로컬 버전과 동일하게 나타납니다. .
호스트 (alert (window.location.host);)를 출력하여 Google지도 API 사이트를 통해 생성 된 키가 실제 서버와 정확히 일치하는지 확인했습니다.
로컬 서버에서 작동하는 이유는 무엇입니까?하지만 라이브 서버에 배포 할 때는 그렇지 않은 사람이 있습니까? 라이브 사이트는 2 개의로드 밸런싱 웹 서버에서 호스팅됩니다. 어떤 도움이 많이 주시면 감사하겠습니다
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA-BU8POZj19wRlTaKIXVM9xTz76xxk4yAELG9u79oXrhnLTB5NRRvAZ-bkKn1x8J68nfRTVOIWNPJEA" type="text/javascript"></script>
<script type="text/javascript">
var map;
var geocoder;
alert(window.location.host);
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("businessMap"));
map.setUIToDefault();
geocoder = new GClientGeocoder();
showAddress('St Margarets Street SW1P 3 London');
}
}
function showAddress(address) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
// Address could not be located.
jQuery('#googleMap').hide();
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
var html = 'Address info for the marker';
marker.openInfoWindow(html);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
}
}
);
}
</script>
:
이
은 렌더링 자바 스크립트입니다.감사합니다.