주소가있는 장소의 데이터베이스가 있고 Google지도에 마커를 추가하고 싶습니다.Google지도 API - 주소로 마커 추가 javascript
기본 마커 만 표시되며 geocoder.geocode()는 아무 것도하지 않는 것처럼 보입니다. 예를 들어 "뉴욕시"에 마커를 추가하려고하는데 성공하지 못했습니다.
<script>
var geocoder;
var map;
var address = "new york city";
geocoder = new google.maps.Geocoder();
function initMap() {
var uluru = { lat: -25.363, lng: 131.044 };
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
var marker = new google.maps.Marker({
position: uluru,
map: map
});
codeAddress(address);
}
function codeAddress(address) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == 'OK') {
var marker = new google.maps.Marker({
position: address,
map: map
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=XXX&callback=initMap"
async defer></script>
위대한 - 내 대답을 받거나 상향 투표 하시겠습니까? 감사합니다 – rafon
물론 나는 이미 투표를 한 적이 있지만 더 많은 평판 포인트를 얻을 때만 자리를 잡을 것입니다. –
방금 질문을 너무 많이 읽었습니다. 당신이 이미 15 명 이상이라고 생각했기 때문입니다. 그것이 더 높은 담당자를 필요로하지 않는 것을 받아들이는 것 :) – rafon