admin管理员组文章数量:1418343
I know how to create a link to google maps with a route between 2 marks using lat and long like this
<a href=',lon&daddr=lat,lon'target='_blank'></a>
The question is how to embed this map using these coordinates into my website as an iframe
I know how to create a link to google maps with a route between 2 marks using lat and long like this
<a href='https://maps.google.?saddr=lat,lon&daddr=lat,lon'target='_blank'></a>
The question is how to embed this map using these coordinates into my website as an iframe
Share Improve this question asked Oct 14, 2015 at 19:04 PHP UserPHP User 2,4226 gold badges52 silver badges99 bronze badges1 Answer
Reset to default 5Use the Embed API
from the documentation
https://www.google./maps/embed/v1/directions
?key=YOUR_API_KEY
&origin=Oslo+Norway
&destination=Telemark+Norway
&avoid=tolls|highwaysThe following URL parameters are required:
origin defines the starting point from which to display directions. The value can be either a place name, address or place ID. The string should be URL-escaped, so an address such as "City Hall, New York, NY" should be converted to City+Hall,New+York,NY. (The Google Maps Embed API supports both + and %20 when escaping spaces.) Place IDs should be prefixed with place_id:. destination defines the end point of the directions.
example:
origin=40.7127837,-74.0059413 (New York, NY)
destination=42.3600825,-71.05888 (Boston, MA)
iframe code:
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google./maps/embed/v1/directions?origin=40.7127837,-74.0059413&destination=42.3600825,-71.05888&key=..." allowfullscreen></iframe>
working example
本文标签: javascriptembed google map with a route between two marks using latitude and longitudeStack Overflow
版权声明:本文标题:javascript - embed google map with a route between two marks using latitude and longitude - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745289553a2651706.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论