Can you programatically draw pins (Markers) by distance on a Custom Google Map route

本小妞迷上赌 提交于 2019-12-11 13:09:08

问题


When going to the Google website and signin in you can click on the “Maps” option from the toolbar menu at the top of the page. Click on the “My Places” button and choose “Create Map.”

There you can select to trace a route, for example, this map: https://maps.google.com/maps/ms?msid=204898944445262337567.0004d03638beb43c93029&msa=0&ll=6.235122,-75.536343&spn=0.003088,0.004823

There's some know way that via JS (other languages are also welcome) , i could put a Pin (Marker) let say, 50 mts from the start of the route i traced? There are some distance data of the route within google, but i haven't found a good tutorial, or any answer on how doing this with these maps.

BTW, I can programatically draw a route and throw the Markers via code this way calculating the distance of the earth, but the thing is that the maps that i'm getting to start with are like the one in the link i wrote before, so the route is actually made by anyone.

Thanks.


回答1:


I have two Mile/Km Marker examples:

  • Km Markers every 2 km
  • Marker at 9.5km and 64.8km

They use a method, GetPointAtDistance, from Mike Williams' epoly utility, which he wrote for the v2 API and I ported to v3

It is possible the same can be done more natively with the v3 geometry library, but that didn't exist when I ported epoly.

You can do the same with a polyline from KML if you render it on the map as a native Google Maps API v3 Polyline using a third party library like geoxml3



来源:https://stackoverflow.com/questions/13764342/can-you-programatically-draw-pins-markers-by-distance-on-a-custom-google-map-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!