Google Maps on your website



Do you know how to put a google map on your website ? If no take a minute to lean.

First off all get your api from http://code.google.com/apis/maps/signup.html

Now put the code on your website and replace with your address

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=YOUR_API_KEY_HERE"
      type="text/javascript"></script>

<script type="text/javascript">
//<![CDATA[
function loadmap() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
var geocoder = new GClientGeocoder();
map.setCenter(new GLatLng(coordonates, coordonates), 13);
map.addControl(new GSmallMapControl());
var address = "your adress";
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(
"<strong>Location</strong>"+
" <br>Type your location");
}
}
);
}
}
// this part uses jquery:
$(window).load(function(){loadmap()});
// if you dont have jquery, do something like:
window.onload = loadmap;
//]]>
</script>

<div id="map" style="width: 300px; height: 400px">
</div>

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

2 Comments »

 
 
 

© 2006 - 2009 BNCScripts.com . All right reserved.