开发者

How to draw line connecting route between several points on Google Map?

开发者 https://www.devze.com 2023-01-04 13:05 出处:网络
I have real-time GPS data stored in a database and I\'m currently pulling the lat/lon from this data and dynamically displaying them as markers on a Google Map.

I have real-time GPS data stored in a database and I'm currently pulling the lat/lon from this data and dynamically displaying them as markers on a Google Map.

What I'm trying to accomplish is to use these lat/lon points to draw a path connecting them. I looked at GDirections, but that seems like it's only used to connect two points together. I'm looking for something where I can send a bunch of GPS coordinates, from start to finish, and have it draw the path on the map connecting t开发者_如何学编程hem.

Any guidance is greatly appreciated.


Apparently it was a lot easier than I thought.

The following will do the trick:

echo "var polyline = new GPolyline([new GLatLng($startlat, $startlon), new GLatLng($endlat, $endlon)], \"#ff0000\", 10);";
echo 'map.addOverlay(polyline);';
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号