I’m using a google map api from this website , thanks to the author.
Here is part of the code:
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0, 0),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
});
<?
$query = mysql_query("SELECT * FROM markers WHERE ID='1'");
while ($row = mysql_fetch_array($query)){
$name=$row['name'];
$lat=$row['lat'];
$lon=$row['lng'];
$desc=$row['address'];
echo ("addMarker($lat, $lon,'<b>$name</b><br/>$desc');\n");
}
?>
center = bounds.getCenter();
map.fitBounds(bounds);
However I’m facing a problem to adjust the zoom level , it set as 14, but no matter what value I changed , it remains the same.
I read from the comments below , someone suggest to remove this line :
map.fitBounds(bounds);
I removed it , but the center of map is move to other location , which I think is (0,0).
Is there any way to fix the zoom problem of this code? I tried to edit all the size though..but I’m not familiar with google map coding.
Thank you.
Replace this:
with:
bounds.getCenter()will return the calculated center of the bounds extended by addMarker()