Try this:
function searchLocationsNear(center) {
clearLocations();
var radius = document.getElementById('radiusSelect').value;
var searchUrl = 'phpsqlajax_search.php?lat=' + center.lat() +
'&lng=' + center.lng() + '&radius=' + radius;
downloadUrl(searchUrl, function(data) {
var xml = parseXml(data);
var markerNodes =
xml.documentElement.getElementsByTagName("marker");
if(markerNodes.length>0){
// heres the original code
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markerNodes.length; i++) {
var name = markerNodes[i].getAttribute("name");
var address = markerNodes[i].getAttribute("address");
var distance =
parseFloat(markerNodes[i].getAttribute("distance"));
var latlng = new google.maps.LatLng(
parseFloat(markerNodes[i].getAttribute("lat")),
parseFloat(markerNodes[i].getAttribute("lng")));
createOption(name, distance, i);
createMarker(latlng, name, address);
bounds.extend(latlng);
}
map.fitBounds(bounds);
// end of original code
} else {
// here set a default map view here as no nearby markers were found
}
});
}
It simply checks if there are any marker nodes returned to the map
from your database - if nodes exist then create the markers else set a
default map view.
Martin.
On Jun 19, 9:08 pm, tarscott <[email protected]> wrote:
> hi,
>
> i have the store locator demo running (http://code.google.com/apis/
> maps/articles/phpsqlsearch_v3.html).
>
> it works, except when i geocode an address without a corresponding
> nearby store location in database (<100 miles away), the map defaults
> to lat 0, lng 180 (middle of Pacific Ocean).
>
> just learning javascript. can anyone point in me in the right
> direction for how to change this? i would like the map to default to
> the original geocoded address even if there's no nearby location, like
> the Ace example.
>
> - tim
--
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.