简体   繁体   English

Google Map方向lon / lat参数

[英]Google Map direction lon/lat params

I m searching for the parameter which I can open a map window directly by putting lon/lat as the source param and get my location itself. 我在搜索参数,可以通过将lon / lat作为源参数直接获取一个地图窗口,并获取我自己的位置。

something like this and and draw direction on map 像这样,然后在地图上绘制方向

https://maps.google.com/maps?from=37.4219720,-122.0841430&to=GET_MY_LOCATION https://maps.google.com/maps?from=37.4219720,-122.0841430&to=GET_MY_LOCATION

Thank u 感谢你

There is no parameter for a automatic detection of your location, you must detect it on your own using eg: navigator.geolocation 没有自动检测您的位置的参数,您必须使用例如navigator.geolocation自行检测它

The correct parameters are not from , to or anything else, they are saddr and daddr . 正确的参数不是fromto或其他任何参数,它们是saddrdaddr

Example: 例:

https://maps.google.com/maps?saddr=52.5191,13.4060&daddr=52.4244,13.7497

Easy! 简单! There is a param for autodection of your location assuming your browser supports geolocation and you haven't blocked it, as with all geolocation calls. 假设您的浏览器支持地理定位并且您没有像所有地理定位调用一样将其阻止,则可以自动确定您的位置。

I'm assuming you want to pass a link directly or through an "a href" tag and not use gmaps api. 我假设您想直接或通过“ a href”标记传递链接,而不使用gmaps api。

https://maps.google.com/maps?saddr=52.5191,13.4060&daddr=current%20Location

A better method would to run a test and verify geolocation is support and turned on. 更好的方法是运行测试并验证地理位置是否受支持并启用。 Check out this gist: https://gist.github.com/bingeboy/5519841 If the success callback fires then you know the URL will work. 查看以下要点: https : //gist.github.com/bingeboy/5519841如果成功回调触发,那么您知道URL会工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM