地理位置 +谷歌地图API?
我想使用 GeoLocation watchPosition 命令来获取手机上的位置数据。有了这些坐标,我想在谷歌地图中绘制一条路线,该路线会随着我进入带有坐标的数组的每个新坐标而更新。
有什么建议我可以如何实现这一目标吗?
提前致谢。
i want to use the GeoLocation watchPosition command, to get location data on a phone. With these coords, I want to draw a route in a google map, which updates with every new coord i get into an array with coords.
any advice how i can achieve this?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我目前正在创建一个地图页面,其功能非常相似。我触发 watchPosition,然后从返回的结果中获取坐标,并将它们传递到我第一次调用的 DirectionsRenderer 对象中。我获取这个 DirectionsRenderer 对象并将其存储在一个数组中。然后,对于每个更新的坐标,我都会使用新坐标更新对象中的纬度/经度值。这似乎运作得很好。
您可以在此处查看我的代码示例。功能虽不完美,但效果还不错。有关详细信息,请参阅 getUserLocation 函数。
I'm currently working on creating a map page that does something very similar. I fire off watchPosition and then take the coords from the returned results and pass them into the a DirectionsRenderer object that I call the first time. I take this DirectionsRenderer object and store it in an array. Then with every updated coords, I update the Lat/Lng values in the object with the new coords. This seems to work pretty well.
You can see an example of my code here. The functionality is not perfect, but it works pretty well. See the getUserLocation function for details.