homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Google / Google Desktop Tools and Google Labs Projects
Forum Library, Charter, Moderator: open

Google Desktop Tools and Google Labs Projects Forum

My Validation for Google Maps V3 seems slighly off - any sugestions?

Msg#: 4392355 posted 7:45 am on Nov 30, 2011 (gmt 0)

Hello Everyone,

I have a little search/mapping tool with Google Maps V3 and works fine and dandy to find locations when the geocoded address is within the radius of any of the locations in my MySQL database. However, when the geocode is successful and the address that was geocoded does not fall inside of the specific radius of the locations, my map centers to the center of the map (right smack dab in the middle of the ocean).

I've been trying to figure out exactly where to place a conditional statement to perhaps alert something like "Sorry no locations in your defined X miles" but I cant seem to figure out exactly where to place it/how to structure it to make it work...I keep breaking the map.

Was trying to place it somewhere in here:

function searchLocationsNear(center) {

var radius = document.getElementById('radiusSelect').value;
var searchUrl = 'generate_xml.php?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius;

downloadUrl(searchUrl, function(data) {

var xml = parseXml(data);
var markerNodes = xml.documentElement.getElementsByTagName("marker");
var bounds = new google.maps.LatLngBounds();

for (var i = 0; i < markerNodes.length; i++) {
//sorry for this being so small...had to wrap in code tag because it was
//throwing an error when trying to post...it just loads variables for markers
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(

createOption(name, distance, i);
createMarker(latlng, name, address);

locationSelect.style.visibility = "visible";
locationSelect.onchange = function() {
var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
google.maps.event.trigger(markers[markerNum], 'click');

Was trying to check if any markers exists and if not send an alert but no luck....any way to throw a conditional statement in there to alert the user instead of the map centering to the middle of the Pacific Ocean? lol


Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google Desktop Tools and Google Labs Projects
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved