Let’s get down on it!
First off, the basic setup:
<script type="text/JavaScript" src="http://maps.google.com/maps/apis/js?sensor=false" />
By doing this you added the reference to Google Maps API in your webpage. Only thing you remember when referencing to Google Maps are setting the sensor parameter.
sensor = true/false – this will tell Google Maps API whether you are using GPS sensor or not. Now, let’s create a canvas.
<div id="map" />
Then, use style to adjust the size of the canvas.
#map {
height: 400px;
width: 450px;
}
Then put them into the jQuery document.ready event to let your browser grab the map object.
$(document).ready(function() {
var tLatlng = new google.maps.LatLng(32.842671, 6.503906);
var myOptions = {
center:latlng,
zoom:10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableAutoPan: false,
navigationControl: true,
navigationControlOptions: { style:google.maps.NavigationControlStyle.SMALL },
mapTypeControl: true,
mapTypeControlOptions: { style:google.maps.MapTypeControlStyle.DROPDOWN_MENU }
};
var map = new google.maps.Map(document.getElementById("map"), myOptions );
var marker= new google.maps.Marker({
position: new google.maps.LatLng(9.931544168615512,76.27632894178791),
title: "My Marker",
clickable: true,
map: map
});
var infoWindow = new google.maps.InfoWindow({
content: "I am here!"
});
// now we attach events
google.maps.event.addListener(marker, "mouseover", function(){
infoWindow.open(map,marker);
});
google.maps.event.addListener(marker, "mouseout", function(){
infoWindow.close(map,marker);
});
});
That’s about it. It is true that most people think Google Maps is so easy. But is it? Let me give you an example. How would you create a certain line like the one in this example?
http://code.google.com/apis/maps/documentation/javascript/examples/layer-kml.html