우편 번호를 기반으로 한 마커가있는 Google지도를 표시하려고합니다. 위도 및 lng 좌표로 우편 번호를 변환했지만지도가 전혀 표시되지 않는 것이 문제입니다. 여기우편 번호가있는 마커가있는 Google지도를 표시 할 수 없습니다.
내가 그렇게하려고하고 방법은 다음과 같습니다
function initialize() {
var lat = '';
var lng = '';
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': 94301}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(lat, lng)
};
var map = new google.maps.Map(document.getElementById("gmap"), myOptions);
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
alert('111');
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
google.maps.event.addDomListener(window, 'load', initialize);
}
심지어
경고 ('111')가 등장하지 않습니다.
내가 뭘 잘못하고 있니?
감사
당신이 자바 스크립트 콘솔을 확인 했습니까? 해당 경고가 표시되지 않는 경우 해당 행에 도달하기 전에 문제가 있다고 의심됩니다. –
콘솔에 오류가없고 경고가 없습니다. 마커에 문제가있는 것 같아요, 단순한지도가 잘 작동하고 버그를 찾을 수 없습니다. – user984621
마커 생성 및 console.log를 제거하면 위도가 작동합니다. –