繁体   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