Home > Google Maps, php, Php programming > Implementing Google Maps using API on your website

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”&gt;

<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.

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: