Test Test - 1 year ago 61
PHP Question

How to turn google maps url into an iframe-friendly url

This is a sample url:


This clearly does not work:

frameborder="0" style="border:0"

How to turn the sample url into a url that works for the iframe? I don't even have to use iframe. I just want to integrate google maps by using urls supplied in the format listed above.

I'm using PHP, if that matters.

Answer Source

Given the URL format you provided I would try to transform it to Google Maps Embed API URL. This requires a API key. You had the following URL:


Transforming it to an embed URL only requires you to extract the address part of the URL you already have. The result will be:


If you alternatively were to receive the URL with no specific place, just a view, it might look like this:


In this example you have to extract the latitude, longitude and zoom level (15z), and create a URL like this:


Reading the API there are two more modes (search and direction) that can be handled in a similar way, but aren't as likely to be used in your case.

As for the extracting I would probably use regex or search and substring, depending on how varying the URLs you receive are.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download