我正在尝试从服务器端使用谷歌地图API中的函数(使用node.js) https://developers.google.com/maps/documentation/javascript/geometry#poly 我想看看某个点是否位于 google map 上从 A 点到 B 点之间的 route 。
isLocationOnEdge(point:LatLng, poly:Polygon|Polyline, tolerance?:number)
我使用了谷歌地图文档上的示例代码,并添加了console.log语句。但是,它没有向控制台输出任何内容。
function initialize() {
var mapOptions = {
zoom: 5,
center: new google.maps.LatLng(24.886, -70.269),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var cascadiaFault = new google.maps.Polyline({
paths: [
new google.maps.LatLng(49.95, -128.1),
new google.maps.LatLng(46.26, -126.3),
new google.maps.LatLng(40.3, -125.4)
]
});
var myPosition = new google.maps.LatLng(43.0, -125.9, 10e-7);
console.log('google.maps.geometry.poly.isLocationOnEdge(myPosition, cascadiaFault))');
}
另一个堆栈溢出问题据说使用在http请求中包含这个url http://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry&sensor=TRUE_OR_FALSE但我知道我需要以某种方式实际包含 islocationonedge 参数。 我应该要求吗 http://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry&sensor=TRUE_OR_FALSE&islocationonedge(point:latlong ,折线:[adfasd,sdfs,adfasdf,adfasd],0.0001)?
非常感谢您的帮助
最佳答案
我会尝试这种方式:
- 检查https://www.npmjs.org/package/googlemaps (moshen/node-googlemaps)
- 阅读此代码 https://github.com/moshen/node-googlemaps/blob/master/lib/googlemaps.js
- f.e.有函数 createEncodedPolyline(points) {..}
- 逐步尝试重新创建对 Google 几何库的请求
关于javascript - 如何使用谷歌地图islocationonedge作为服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27302919/