I\'m working with multiple map markers. Currently I use map.fitBounds(bounds); in my JavaScript to resize the map. bounds contains multiple LatLng
//Custom zoom if you have just type of geocode response
function get_node(node_name){
return document.getElementById(node_name);
}
var map_options = {};
var options = {
'zoom' : LB_listing.zoomopt,
'minZoom' : 3,
'center' : latlng,
'mapTypeId' : google.maps.MapTypeId.ROADMAP
};
map_options.map = new google.maps.Map(get_node('googleMap'), options);
geocoder = new google.maps.Geocoder();
var address = $("#search_location").val();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
switch(results[0].types[0]){
case 'street_address':
map_options.zoomopt = 6;
break;
case 'route':
map_options.zoomopt = 14;
break;
case 'bus_station':
map_options.zoomopt = 14;
break;
case 'intersection':
map_options.zoomopt = 6;
break;
case 'political':
map_options.zoomopt = 14;
break;
case 'country':
map_options.zoomopt = 5;
break;
case 'administrative_area_level_1':
map_options.zoomopt = 6;
break;
case 'administrative_area_level_2':
map_options.zoomopt = 6;
break;
case 'administrative_area_level_3':
map_options.zoomopt = 6;
break;
case 'administrative_area_level_4':
map_options.zoomopt = 6;
break;
case 'administrative_area_level_5':
map_options.zoomopt = 6;
break;
case 'colloquial_area':
map_options.zoomopt = 6;
break;
case 'locality':
map_options.zoomopt = 11;
break;
case 'ward':
map_options.zoomopt = 6;
break;
case 'sublocality':
map_options.zoomopt = 6;
break;
case 'neighborhood':
map_options.zoomopt = 14;
break;
case 'premise':
map_options.zoomopt = 6;
break;
case 'subpremise':
map_options.zoomopt = 6;
break;
case 'postal_code':
map_options.zoomopt = 6;
break;
case 'natural_feature':
map_options.zoomopt = 6;
break;
case 'airport':
map_options.zoomopt = 6;
break;
case 'park':
map_options.zoomopt = 6;
break;
case 'point_of_interest':
map_options.zoomopt = 6;
break;
default:
map_options.zoomopt = 6;
break;
}
map_options.newLocation(results[0].geometry.location.lat(),results[0].geometry.location.lng());
}else {
$('#message_error').show().delay(3000).fadeOut(1000);
$('#message_error_msg').html("Geocode was not successful for the following reason: " + status);
}
});
map_options.newLocation = function(newLat,newLng) {
map_options.map.setCenter({
lat : newLat,
lng : newLng
});
map_options.map.setZoom(map_options.zoomopt);
}