簡體   English   中英

獲取特定緯度+經度或街道地址的Placeid

[英]Get placeid for specific Latitude + Longitude or street address

在Excel中,我同時擁有Street Address和Lat + Long,並嘗試從Google Places API Web服務獲取PlaceID。 我研究了Geocoding API和Places API,並進行了一些VBA測試。 獲取特定地點的PlaceID的唯一方法是進行文本搜索或附近搜索。

有沒有辦法從您直接在VBA中獲得的地址獲取它? 我看過一個演示網站,該網站使用JavaScript獲取PlaceID,但不知道如何將JavaScript集成到Excel + VBA中。

聽起來像是您想要NearestSearch (不確定為什么您不認為這不能滿足您的需求):

鄰近搜索可讓您按關鍵字或類型搜索指定區域內的地點。 鄰近搜索必須始終包含位置,可以通過以下兩種方式之一指定位置:

  • LatLngBounds。
  • 定義為location屬性(將圓心指定為LatLng對象)和半徑(以米為單位)的組合的圓形區域。

通過調用PlacesService的附近的Search()方法來啟動“附近的地方”搜索,該方法將返回PlaceResult對象的數組。

小提琴

代碼段:

 var map; var infowindow; function initialize() { var pyrmont = new google.maps.LatLng(-33.8665433, 151.1956316); map = new google.maps.Map(document.getElementById('map-canvas'), { center: {lat:40.689249,lng:-74.0445}, zoom: 15 }); var request = { location: {lat:40.689249,lng:-74.0445}, radius: 10 }; infowindow = new google.maps.InfoWindow(); var service = new google.maps.places.PlacesService(map); service.nearbySearch(request, callback); } function callback(results, status) { if (status == google.maps.places.PlacesServiceStatus.OK) { for (var i = 0; i < results.length; i++) { createMarker(results[i]); } } } function createMarker(place) { var placeLoc = place.geometry.location; var marker = new google.maps.Marker({ map: map, position: place.geometry.location }); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(place.name+"<br>"+place.place_id); infowindow.open(map, this); document.getElementById('placeId').innerHTML = place.name+"<br>"+marker.getPosition().toUrlValue(6)+"<br>"+place.place_id; }); } google.maps.event.addDomListener(window, 'load', initialize); 
 html, body, #map-canvas { height: 500px; width: 500px; margin: 0px; padding: 0px } 
 <script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script> <div id="placeId"></div> <div id="map-canvas" style="border: 2px solid #3872ac;"></div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM