Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Implementing Google Maps using API on your website

Hello Friends,

Are you looking to implement Google Map in your website ?? Do you have a Real estate property website ? If yes, the you must implement(integrate) Google map using API key into your website. Recently i have implemented the Google map into one of my client's website and it is very easy to implement.  Here i am showing you the step by step way to integrate the Google map into your website.

Below are the steps.

 

<?php

require(‘GoogleMapAPI.class.php’);

$map = new GoogleMapAPI(‘map’);

$map->setAPIKey(‘APIKEYHERE’);

$map->addMarkerByAddress(‘London SW66HX’,'Our Address’,'<b>London <br />SW66HX</b>’);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns:v="urn:schemas-microsoft-com:vml">

<head>

<?php $map->printHeaderJS(); ?>

<?php $map->printMapJS(); ?>

<!– necessary for google maps polyline drawing in IE –>

<style type="text/css">

v\:* {

behavior:url(#default#VML);

}

</style>

</head>

<body onLoad="onLoad();">

<?php $map->printMap(); ?>

</body>

</html>

 

1) If you don't have Google map API than
Create the one from here. (Its a free)
2) Download GoogleMapAPI.class.php Class.

3) Include GoogleMapAPI.class.php file in your web page.

<?php
    require('GoogleMapAPI.class.php');
?>

4) Add these three statement. Change your Google Map API key in second statement and provide address for which you want to show Google Map in third statement.

<?php
    $gmap = new GoogleMapAPI('map');
    $gmap->setAPIKey('APIKEYHERE');
    $gmap->addMarkerByAddress('Ahmedabad India','Address','<b>Ahmedabad <br />Gujarat <br /> India</b>');
?>

5) Write below code in <head></head> tags.

<head>
<?php $gmap->printHeaderJS(); ?>
<?php $gmap->printMapJS(); ?>
<!– necessary for google maps polyline drawing in IE –>
<style type="text/css">
  v\\:* {
    behavior:url(#default#VML);
  }
</style>
</head>

6) Call onLoad() function in body tag.
<body onLoad="onLoad();">
7) Write below statement to show the Google map as per provided address.

<?php $gmap->printMap(); ?>

Thats it.

 

If you find any problem in this than let me know by comment.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database and Open-source, enter your email address below. We will send you free tutorials.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
Share:

11 Comments

  • Bindu

    I tried all the above but i am getting an error message “DB Error: connect failed”. I read many posts and every one has the same as shown above but no one tells if we need and DB.php file and PEAR.php file etc. Can some one tell in detail about how it really works, i mean if we need DB.php and PEAR.php etc. or we do not need them.

    Thanks,
    Bindu

  • Bindu

    I tried all the above but i am getting an error message “DB Error: connect failed”. I read many posts and every one has the same as shown above but no one tells if we need and DB.php file and PEAR.php file etc. Can some one tell in detail about how it really works, i mean if we need DB.php and PEAR.php etc. or we do not need them.

    Thanks,
    Bindu

  • Bindu

    Oh well, now i am getting error message “DB Error: insufficient permissions” i have checked all the permission even then i am getting this message.

  • Bindu

    Oh well, now i am getting error message “DB Error: insufficient permissions” i have checked all the permission even then i am getting this message.

  • Dskanth 99

    I got a blank page after doing all the above things..

Leave a Reply

Your email address will not be published.