2017-06-01 10 views

答えて

0

私はあなたがGoogleのジオコーディングApiを探していると思います。

あなたはこのような何かを要求を送信する:あなたは

「の結果 - 幾何学 - 場所 - 緯度/経度」の経度緯度とを得ることができるところに大きなJSONオブジェクトが返され、その後 https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

{ 
"results" : [ 
    { 
    "geometry" : { 
     "location" : { 
      "lat" : 37.4224764, 
      "lng" : -122.0842499 
     }, 
... 
... 

は、いくつかのより多くの情報https://developers.google.com/maps/documentation/geocoding/intro

0

最初のロードのために、ここで見てくださいライブラリ:

<script type="text/javascript" 
     src="https://maps.googleapis.com/maps/api/js? 
     key=YOUR_API_KEY&libraries=places"> 
    </script> 

次いで、特定の場所の詳細を見つける:

<script> 
function initMap() { 
     var map = new google.maps.Map(document.getElementById('map'), { 
      center: {lat: -33.866, lng: 151.196}, 
      zoom: 15 
     }); 

     var infowindow = new google.maps.InfoWindow(); 
     var service = new google.maps.places.PlacesService(map); 

     service.getDetails({ 
      placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4' 
     }, function(place, status) { 
      if (status === google.maps.places.PlacesServiceStatus.OK) { 
      var marker = new google.maps.Marker({ 
       map: map, 
       position: place.geometry.location 
      }); 
      google.maps.event.addListener(marker, 'click', function() { 
       infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + 
       'Place ID: ' + place.place_id + '<br>' + 
       place.formatted_address + '</div>'); 
       infowindow.open(map, this); 
      }); 
      } 
     }); 
     } 

は、所望の位置の緯度と経度を置き換えます。詳細については、

は参照:

https://developers.google.com/maps/documentation/javascript/places#place_details

およびたとえば:

https://developers.google.com/maps/documentation/javascript/examples/place-details

関連する問題