Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setbounds on google maps api v3

I'm trying to set the bounds of a map fitbounds doesnt work because it puts some space around the bounds therefore doing

{{{map.fitBounds(map.getBounds())}}}

a few times will quickly zoom the map out

I need to be able to do

{{{map.setBounds(map.getBounds())}}}

and for nothing to happen

please note I am using v3 of the api and therefore do not have access to getBoundsZoomLevel

like image 553
msaspence Avatar asked Mar 18 '10 08:03

msaspence


People also ask

What is the largest image size allowed in statistics maps API?

The maximum size we can provide is 2048 x 2048 pixels.

Can you customize Google Maps API?

The Google Maps APIs now support you in creating beautiful styled maps for your Android and iOS apps as well as your website using the same JSON style object.


1 Answers

If I'm not mistaken, I'm assuming you want all your points to be visible on the map with the highest possible zoom level. I accomplished this by initializing the zoom level of the map to 16(not sure if it's the highest possible zoom level on V3).

var map = new google.maps.Map(document.getElementById('map_canvas'), { zoom: 16
                                        , center: marker_point
                                        , mapTypeId: google.maps.MapTypeId.ROADMAP
});

Then after that I did the bounds stuff:

var bounds = new google.maps.LatLngBounds();

//you can have a loop here of all you marker points
//begin loop
bounds.extend(marker_point);
//end loop

map.fitBounds(bounds);

Result: Success!

like image 99
Lester S Avatar answered Oct 02 '22 04:10

Lester S