Is there a was of automatically setting the zoom level based on the size of the country that the map has been centered on?
maps.google.com does exactly what I need,
If you don't want to use the geocoder client from google, because of usage limitations you could use your own list. You can get one from this github repo.
Here is a code example using jQuery's getJSON function and google maps API v3:
function initialize() {
// read the list of countries
$.getJSON('countries.json', function (countries) {
// will use the country with index 40 (Cyprus)
var index_country = 40;
var myOptions = {
center: new google.maps.LatLng(
countries[index_country].center_lat,
countries[index_country].center_lng),
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// set the bounds of the map
var bounds = new google.maps.LatLngBounds(
new google.maps.LatLng(countries[index_country].sw_lat, countries[index_country].sw_lng),
new google.maps.LatLng(countries[index_country].ne_lat, countries[index_country].ne_lng) );
map.fitBounds(bounds);
});
}