tags:

views:

21

answers:

1

Hello,

I want to create google map using a pre-defined set of bounds.

So instead of the usual

var map = new GMap2(document.getElementById('map'));

map.setCenter(new GLatLng(0,0),5);

I want to do something like

var map = new GMap2(document.getElementById('map'));

map.setBounds(new GLatLng(10,10), new GLatLng(20,20));

Is this possible?

thank you.

A: 

Yes, see below:

var map = new GMap2(document.getElementById('map'));    
var bounds = new GLatLngBounds(new GLatLng(10,10), new GLatLng(20,20));
map.setCenter(bounds.getCenter());
map.setZoom(map.getBoundsZoomLevel(bounds));
Ossama