Reputation: 18649
I have this page where I have a listing of items per state. If I try to do
map.fitBounds(bounds);
Then the map suddenly shifts to the ocean. What I wanted it to do was to fit around the area of the markers.
Here is the test page for this:
http://www.comehike.com/outdoors/terrain.php?type=hills&geo=state&state_id=1
Any idea what is going wrong?
Thanks!
Upvotes: 0
Views: 1294
Reputation: 3743
When you initialize bounds
at the end of initializeTerrain
there are no markers on the map. Therefore it defaults to that spot in the Pacific when you later call map.fitBounds(bounds)
. You need to extend the bounds after each of the markers are added.
var myLatlng = new google.maps.LatLng( 32.533470 , -87.786118 );
bound.extend(myLatlng);
...repeat for each marker.
should do the trick
Upvotes: 1
Reputation: 14539
that location is the center of the map, probably meaning that the location wasn't found. Maybe an incorrect syntax somewhere?
Upvotes: 1