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>
Create the one from here. (Its a free)
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.
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.






I am
about 1 year ago
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
about 1 year ago
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
about 1 year ago
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.
about 1 year ago
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.
about 1 year ago
I got a blank page after doing all the above things..
about 1 year ago
Which is better PHP or .NET as per development in future
about 10 months ago
very good but how can I call the address from database I am new to php plz help
about 10 months ago
I need exact code for google map API London using php/mysql javascript for Real Estate website.pls help me as soon as possible
about 3 months ago
Hi,
I get your script to work fine but I do not get any map (the google frame is grey) even if I put your script $gmap->addMarkerByAddress(‘Ahmedabad India’,'Address’,’Ahmedabad Gujarat India‘);
What did I do wrong?
Thanks