Reputation: 9630
I want to convert a Google map URL to embed iframe so that I can show it to html. For example take this url:
When you go to this url and click "Share" Google gives you the embed map url in iframe like this:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d13007260.396144057!2d-104.66829755128677!3d37.257180679921!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x54eab584e432360b%3A0x1c3bb99243deb742!2sUnited+States!5e0!3m2!1sen!2s!4v1459600802389" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
My Query is how to parse the url "https://www.google.com/maps/place/United+States/@37.2571807,-104.6682976,5z/data=!3m1!4b1!4m2!3m1!1s0x54eab584e432360b:0x1c3bb99243deb742?hl=en" and convert it to iframe one?
Upvotes: 0
Views: 2803
Reputation: 6173
You cannot parse that URL to get the share iframe
. If you compare the two, the data is DIFFERENT.
You can then use this regex: @(-?\d*[.]?\d*,-?\d*[.]?\d*),(\d)z
.
The URL will be https://www.google.com/maps/embed/v1/view
?key=YOUR_API_KEY
¢er=$1
&zoom=$2
&maptype=satellite
, where $1
and $2
are from the regex.
Upvotes: 0