Я пытаюсь геокодировать следующий адрес -> Noguera 429 San Antonio de Padua с API Карт Google. Адрес поступает из базы данных и хранится в адресе переменной. Это мой код:Google Maps Геокодирование не работает
var address = '<?php echo $cerrajero["direccion"]?>'+' '+'<?php echo $cerrajero["ciudad"]?>';
var myCenter;
function initialize(){
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
"address": address
},function(results){
myCenter = results[0].geometry.location;
});
var mapProp = {
center:myCenter,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker=new google.maps.Marker({
position:myCenter,
icon:'css/images/pin.png'
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
, а затем:
<div id="googleMap" class="map" style="height:250px;"></div>
и, наконец:
.map{
margin: 0 0 18px 0;
width: 100%;
}
Но моя карта не отображается. Он просто показывает серый блок, что-то не так с javascript?
PS: Адрес переменной в порядке, я проверил его с помощью консоли.
Спасибо !! Это сработало! –