2013-03-08 4 views
-1

Я могу настроить кнопку на карте, но я не могу получить широту и долготу этой точки. Вот мой код. Может кто-нибудь помочь с этим?получить широту и долготу в google map

Благодаря

function codeaddress() { 
    var geocoder; 
    //map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 
    geocoder = new google.maps.Geocoder(); 

    var address = document.getElementById("address").value; 

    geocoder.geocode({ 'address': address }, function (results, status) { 
     if (status == google.maps.GeocoderStatus.OK) { 


      map.setCenter(results[0].geometry.location); 
      var marker = new google.maps.Marker({ 
       animation: google.maps.Animation.BOUNCE, 
       flat: false, 
       map: map, 
       position: results[0].geometry.location 

      }); 

      var latt = document.getElementById("latitude"); 
      latt.value = results[0].geometry.location.getlatitude(); 
      alert(latt.value); 

     } else { 
      alert("Geocode was not successful for the following reason: " + status); 
     } 
    }); 

} 
+0

Это нуждается в базовой отладке первым. Что именно происходит не так? –

+0

Вы пробовали результаты [0] .geometry.location.lat() – Rafe

+0

Rafe, опробованные результаты [0] .geometry.location.lat(). Не получил широту. – user2147447

ответ

Смежные вопросы