Google 静态地图,绘制自定义路线方向

Google Static Maps, draw custom route direction

我有一个 React 应用程序 API 调用 Google 静态地图服务,以获取地图。

我想知道是否可以在两个地理位置之间绘制自定义方向线。目前,我正在画那条线,但它看起来……很难看:

我要的是曲线,带平面图标,像这样:

可能吗?

Google 静态地图API 允许绘制测地线

geodesic: (optional) indicates that the requested path should be interpreted as a geodesic line that follows the curvature of the earth. When false, the path is rendered as a straight line in screen space. Defaults to false.

https://developers.google.com/maps/documentation/static-maps/intro#Paths

将此选项添加到您的路径参数。此外,您可以添加与测地线路径重叠的自定义平面图标。

例如,

https://maps.googleapis.com/maps/api/staticmap?size=600x400&path=weight%3A5%7Ccolor%3A0x111111%7Cgeodesic%3Atrue%7CAmsterdam%7CTashkent&markers=icon%3Ahttps%3A%2F%2Fcdn0.iconfinder.com%2Fdata%2Ficons%2Fshopping-and-e-commerce-2%2F400%2FCargo_plane_icon-64.png%7C47.557774%2C43.044347&key=YOUR_API_KEY

运行 下面的代码片段可以看到它的实际效果

<img src="https://maps.googleapis.com/maps/api/staticmap?size=600x400&path=weight%3A5%7Ccolor%3A0x111111%7Cgeodesic%3Atrue%7CAmsterdam%7CTashkent&markers=icon%3Ahttps%3A%2F%2Fcdn0.iconfinder.com%2Fdata%2Ficons%2Fshopping-and-e-commerce-2%2F400%2FCargo_plane_icon-64.png%7C47.557774%2C43.044347&key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&signature=Y-EtK76SDUyAao0uuGniNx3LhWs="
  title="sample geodesic path" />

希望对您有所帮助!