Hi.
Try updating your code so it knows how many markers have been created
and sets the map bounds based on that:
[code]
var visibleMarkersCount=0;
for (var i = 0; i < markerNodes.length; i++) {
var id = markerNodes[i].getAttribute("property_id");
var city_id = markerNodes[i].getAttribute("city");
var state_id = markerNodes[i].getAttribute("state");
var country_id = markerNodes[i].getAttribute("country");
var postal_code = markerNodes[i].getAttribute("postal_code");
var address = markerNodes[i].getAttribute("street");
var price = markerNodes[i].getAttribute("price");
var bedrooms = markerNodes[i].getAttribute("bedrooms");
var bathrooms = markerNodes[i].getAttribute("bathrooms");
var category_id = markerNodes[i].getAttribute("type");
var living_area = markerNodes[i].getAttribute("sqft");
var lot_area = markerNodes[i].getAttribute("lotsqft");
var listing_type_id = markerNodes[i].getAttribute("listing");
var building_name = markerNodes[i].getAttribute("building_name");
var distance = parseFloat(markerNodes[i].getAttribute("distance"));
var googlemap_ltgooglemap_ln = new google.maps.LatLng(
parseFloat(markerNodes[i].getAttribute("googlemap_lt")),
parseFloat(markerNodes[i].getAttribute("googlemap_ln")));
createOption(address, distance, i+1);
createMarker(googlemap_ltgooglemap_ln, address, city_id, state_id,
country_id, postal_code, price, bedrooms, bathrooms, category_id,
living_area, lot_area, building_name, listing_type_id, id);
bounds.extend(googlemap_ltgooglemap_ln);
visibleMarkersCount++;
}
switch(visibleMarkersCount){
case 0:
// no markers have been created
// set map zoom and center accordingly - or just it leave
it as it
is
break;
case 1:
// a single marker has been created
// center on the marker but set a zoom level that's not
fully zoomed
in
break;
default:
// two or more markers have been created
// fit the map to the markers
map.fitBounds(bounds);
}
[/code]
http://www.w3schools.com/js/js_switch.asp
Martin.
On Oct 31, 2:40 pm, Am <[email protected]> wrote:
> I wasn't able to find another post similar to my question, but I'm hoping
> someone can help walk me through this.
>
> How do I set the zoom level of the map when I search for properties? I
> don't have a url, so I'm not sure how to set the zoom. For example: When I
> search for an address that does not have a property in the search radius,
> my map zooms in 100% to the address. It does the same if there is only 1
> property in the search radius. How do I change it so it only zooms in part
> way, like 50% (or zoom=7)? I don't have a url anywhere in my code; it's all
> php and javascript.
>
> http://www.rentalmatch101.com.php5-20.dfw1-1.websitetestlink.com/goog...
>
> Thank you for your help.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.