3yrs back, when I was first time assigned to integrat Google Map; I was so confused what to do!! But, when I finish my work, I feel it is very easy task. For embedding Google Map in your own web page,you have to write some lines of codes. I am explaining it step by step…
- 1st u have to download GoogleMapAPI.class.php
- Put this file in your project’s root folder. For me I put it in the E:/REDWOODONLINE/GoogleMapAPI.class.php
- On the top, out side the body tag [ <body></body>] you have to write some lines of code. those are as follows:
- You must write those line inside the php tag [ <?php ?> ]
- After you include the googlemapapi class, all the functions will be work automatically.
- In the line number# 5, you can see; you have to set up Google Map API Key. this key will be different for different pages. in my next post I will explain how to get this key.
- in the line number#13, you can see PostCode is bolder. this postcode we get from the database by query.if the postcode is not valid, it will not show any perfect MAP.
- inside the body tag [ <body></body>], where you want to show your map in the web page, there you have to write some line of codes. those are as follows:
- <?php $map->printMap(); ?>
-
<script type="text/javascript" charset="utf-8">
-
// <! [CDATA[
-
if (GBrowserIsCompatible()) {
-
document.write('<div id="map" style="width: 265px; height: 155px"></div>');
-
}
-
else{
-
document.write('<b>Javascript must be enabled in order to use Google Maps.</b>');
-
}
-
// ]]>
-
</script> <b>Javascript must be enabled in order to use Google Maps.</b><span data-mce-type="bookmark" id="__mce"></span>
-
<noscript>
-
<b> Javascript must be enabled in order to use Google Maps.
-
</b>
-
</noscript>
- When you will write the 1st line, I mean $map->printMap(); Map will be shown on your web page. other lines are for prevent JScript error.
For more help you have to see the following web pages:
Google Map API, Developers Guide
here is the image, after embedding map
Advertisement
Like this:
Be the first to like this post.
very nice and useful post. I search a lot. your post is very clear and informative. this article helps me a lot.