Search This Blog

Friday, May 22, 2009

Adding more than one marker in Google Map

As you all know , if we want to point a specific location in Google Map we use "Markers". Markers are specified in Google Map API but, in default it points only to one location.

But if we want to add more than one marker to a Google Map what shall we do?
This question got into my mind when I was doing my Internet Programming coursework in the First year.

I browsed for a solution but I found very advanced piece of coding and most of them not working.
Because of this I wrote a simple coding for this.

The simple modification is as follows:

center=new Array(2);
marker=new Array(2);
center[0]=new GLatLng(7.181194, 79.883806);
center[1]=new GLatLng(6.8219444444,79.8861111111);
for(i=0;i<2;i++)
{
map.setCenter(center[i], 13);
marker[i] = new GMarker(center[i], {draggable: false});
map.addOverlay(marker[i]);
}

-Chandira