I've checked the values within the bounds variable during & after the
looping, and they look right. And the markers that I am setting in
the same loop are being correctly placed. The only thing that does
not seem to be working is the fitBounds function, setting the zoom
level to show all the markers.
The code looks like:
var myOptions = {
zoom:10,
center: new google.maps.LatLng(-34.397, 150.644),
scaleControl: true,
navigationControl: false,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map($("#map_result_map").get(0),
myOptions);
var map_bounds = new google.maps.LatLngBounds();
jQuery.each(items, function(i, row) {
var item_id = row[0];
var item_name = row[1];
var item_addr_lat = row[5];
var item_addr_lng = row[6];
if (item_addr_lat != null) {
var current_marker_location = new google.maps.LatLng(item_addr_lat,
item_addr_lng);
var marker = new google.maps.Marker({
position: current_marker_location,
map: map,
title: item_name
});
map_bounds.extend(current_marker_location);
}
});
map.set_center( map_bounds.getCenter( ));
map.fitBounds(map_bounds);
> athttp://
code.google.com/p/geoxml3/source/browse/trunk/geoxml3.js.