谷歌地图折线:从原点计算端点
我想使用 Google 地图绘制折线。
我已经阅读了 API 并做了一些研究,但我仍然有一个基本问题。
信息:
lat: 63.43243500
lon: 10.37045667
angle: 230 degrees (0 = north)
我如何制作一条 60 米长、源自原始纬度/经度、角度为 230 度的折线?
I want to draw a polyline using Google Maps.
I have read the API and did some research, but i am still left with a fundamental question.
Information:
lat: 63.43243500
lon: 10.37045667
angle: 230 degrees (0 = north)
How can i make a polyline that is 60 meters long that originates from the original lat / lon with a angle of 230 degrees?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要计算直线的端点(纬度,经度)。这可以使用 google.maps.geometry.spherical 命名空间。它具有三个必需参数:起始纬度/经度点、行驶距离和航向角。
以下是适合您情况的示例:
来自折线示例 ,您可以从这些点创建多段线,如下所示:
更新: 您还需要确保包含
geometry
库,默认情况下不包含该库。按照此处的说明操作,您需要更改引导程序请求:You need to calculate the endpoint of the line in (lat,lon). This can be done using the
calculateOffset
function in the google.maps.geometry.spherical namespace. It has three required parameters: the starting lat/lng point, the distance to travel, and the heading angle.Here's an example for your situation:
From the Polyline example, you can create a Polyline from these points as:
Update: You also need to make sure that you include the
geometry
library, which is not included by default. Following the instructions here, you need to change your bootstrap request to: