How to Quickly display address on google map using Google Maps Embed API

In this quick tutorial we’ll talk about how to Quickly display address on google map using Google Maps Embed API, If You have you stored lot’s of addresses in your database without latitude and longitude and looking for solution to dynamically show each address on google map then this Google Maps Embed API is very helpful, because it is so quick to display addresses without using javascript google map api, You only need to generate API key and then pass your API key and address on Google Maps Embed API and it’ll quickly display address location on google map see following example.



First generate API Key from Here

After that pass your generated API key and address on following code..

<?php
$address = "Okhala phase 2 new delhi";
$address = str_replace(" ","+", $address);
?>
<iframe
  width="100%"
  height="400"
  frameborder="0" style="border:0"
  src="https://www.google.com/maps/embed/v1/place?key=YOUR_API_KEY
    &q=<?= $address ?>">
</iframe>

See Demo:

If you have latitude and longitude then you can also display street view on map by following code.

<?php
$lat = 46.414382;
$lng = 10.013988;
?>
<iframe
  width="100%"
  height="400"
  frameborder="0" style="border:0"
  src="https://www.google.com/maps/embed/v1/streetview
  ?key=YOUR_API_KEY
  &location=<?= $lat ?>,<?= $lng ?>">
</iframe>



2 Replies to “How to Quickly display address on google map using Google Maps Embed API”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.