• 0

[JAVA]Google Maps Help


Question

I need alittle help with google maps. I want to center the map by the markers that i place on it and i dont know how to do so.

I have a page where it reads some info from a database and place the markers on the map by regions and i want it to center by each region each time.

This i the code i have now:

<script type='text/javascript'>
function initialize() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById('map_canvas'));
		map.setCenter(new GLatLng(0,0),0);
		map.addControl(new GSmallMapControl());	
		function createMarker(point,html) {
			var marker = new GMarker(point);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(html);
			});
			return marker;
		}

		var icon = new GIcon();
		icon.image = 'test.php';
		icon.iconSize = new GSize(25, 25);
		icon.shadowSize = new GSize(91, 62);
		icon.iconAnchor = new GPoint(15, 15);
		icon.infoWindowAnchor = new GPoint(31, 8);

		var map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GLargeMapControl());		
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(35.88905,82.08984),2);


HERE IT READS THE INFO FROM THE DATABASE


	}

}

</script>
</head>
<body onload='initialize()' onunload='GUnload()'>
<div id='map_canvas' style='width: 600px; height: 350px'></div>
</body></div><br>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.