2016-09-21 7 views
0

JavaScriptを使用して位置の座標を取得したいと考えています。しかし私は私のオートコンプリートに問題があります。私は同様のクエリに出くわしましたが、解決策のうちのどれも私を助けませんでした。Google Maps APIが緯度または経度を返さず、オートコンプリートが機能しない

マイコード:

<html> 
<head> 
<title>Geocoding</title> 
</head> 
<body> 
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script> 
<script type="text/javascript"> 
    google.maps.event.addDomListener(window, 'load', initilize); 
    function initilize() { 
     var autocomplete = new google.maps.places.Autocomplete(document.getElementById('txtautocomplete')); 
     google.maps.events.AddListener(autocomplete, 'place_changed', function() { 
      var places = autocomplete.getPlace(); 
      var location = "<b>Location:</b>" + places.formatted_address + "<br/>"; 
      location += "<b>Latitude:</b>" + places.geometry.location.lat + "<br/>"; 
      location += "<b>Longitude:</b>" + places.geometry.location.lng + "<br/>"; 
      document.getElementById('lblresult').innerHTML = location; 
     }); 

    }; 
</script> 
location:<input type="text" id="autocomplete" placeholder="Enter the address"/> <br/> <br/> 
<label id="lblresult"></label> 

+0

http://stackoverflow.com/questions/7135722/display-location-using-longitude-latitude-coordinates-google-maps – AGrammerPro

答えて

関連する問題