生成静态地图图像,其中包含两个标记和中间的弧,服务器端

时间:2016-03-19 10:47:00

标签: php node.js google-maps mapbox cartodb

我的问题类似于" Curved line between two near points in google maps"但我想将地图生成为静态图像服务器端(PHP或NodeJS),以便可以在离线环境中使用。

简而言之,我有两套纬度和经度,我想在其间放置标记并在其间绘制非测地弧,然后将地图保存为图像。不需要Google地图。

这基本上就是我想要实现的目标:

Static map image with curved line between two markers

3 个答案:

答案 0 :(得分:0)

使用PHP(需要ImageMagick)和开放式街道地图(通过curl)完成。

请注意:在实施此解决方案之前,您必须了解使用Open Street Map的许可和条款,以确保可以接受。

https://operations.osmfoundation.org/policies/tiles/

TODO:改善两点之间的贝塞尔曲线

TODO:检查切片服务器的响应以确保它是图像

service.events().get(calendarId='primary', eventId=<meeting_id>).execute()

答案 1 :(得分:0)

您可以按照以下方法在ImageMagick中绘制2点贝塞尔曲线:改变圆弧半径。

p1=172,197
p2=483,231

convert map.png -fill none -stroke red -strokewidth 2 -draw "path 'M $p1   A 1,1  0  0,1 $p2'" map_arc1.png

enter image description here

convert map.png -fill none -stroke red -strokewidth 2 -draw "path 'M $p1   A 3,2  0  0,1 $p2'" map_arc2.png

enter image description here

convert map.png -fill none -stroke red -strokewidth 2 -draw "path 'M $p1   A 4,2  0  0,1 $p2'" map_arc3.png

enter image description here

答案 2 :(得分:0)

这是我的 NodeJS 使用TurfJSSVG.JS和静态Google Maps:Runkit Link对其进行处理。只需替换GMAPS_API_KEY

初步结果如下

enter image description here

和一些测地校正仍然是必需的。尽管如此,这应该可以将您设置在正确的路径上。

相关问题