在那里我得到了googlemaps api node.js的例子

是否有任何例子如何使用谷歌地图API使用node.js检索我的位置和比较我的坐标与存储在MongoDB中的位置?

这里是Google API文档,指的是asynchronous加载API。 由于这个例子是在JavaScript中,它应该适用于任何NodeJS应用程序。

至于比较你的坐标和其他人,这种逻辑可以完成而不使用API​​,因为它只是一个math比较。

如果要将user.longitudeuser.latitudevariables存储在服务器端,然后在您的站点上创build的地图中dynamic显示它们,则只需要调用地图选项和标记就可以了:

 var myLatlng = new google.maps.LatLng(user.latitude, user.longitude ); var mapOptions = { center: myLatlng, zoom: 8 }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map, title:"Hello World!" }); 

你的HTML看起来像什么地方

 <div id="map-canvas"/> 

通读我已经链接到的Google Maps JavaScript API。 标记和地图样式有很多不同的选项。