tags:

views:

378

answers:

2

Can I display a Country's Map passing the country name as parameter to Google Maps API? The display field area is same for all the countries so the zoom level should adjust automatically to fit the corresponding country in.

I have tried Using GLatLongBounds but its no good as USA in 800X800 is fine but Japan is a Dot.

A: 

I'm pretty confident you'll need to pass the zoom level as well as the country name (or lat/long coords) to get the proper bounding.

jerebear
But how to find the proper zoom level for a country. USA zoom level will definitely be lesser(zoomed out) than Japan's.I mean i need to show the whole country in a fixed area, lets suppose 600X600px.I have the lat/long pair for the countries.
Anuj Kabra
+1  A: 

If you are already have the GLatLongBounds of the country, you can just do: GMap2.getBoundsZoomLevel(GLatLongBounds) to get the appropriate zoom level to show those bounds.

From the Google Maps API:

getBoundsZoomLevel(bounds:GLatLngBounds)

Returns the zoom level at which the given rectangular region fits in the map view. The zoom level is computed for the currently selected map type. If no map type is selected yet, the first on the list of map types is used.

James