function geoLocator_getCities() { document.getElementById('geoLocatorAPI').value = 'GPbNPOTrnFObfXNbk0AFKlIOk'; jQuery.getJSON( "http://api.mppmarketinggroup.com/locator/api.php?api=GPbNPOTrnFObfXNbk0AFKlIOk&getcities=1&callback=?", function(j) { var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } $("#geoLocatorCities").html(options); } ); } function geoLocator_listAll() { jQuery.getJSON( "http://api.mppmarketinggroup.com/locator/api.php?api=GPbNPOTrnFObfXNbk0AFKlIOk&listall=1&callback=?", function(j) { geoLocator_generateResultsOutput( j, 'all', '' ) } ); } function geoLocator_citySearch( api, city ) { jQuery.getJSON( "http://api.mppmarketinggroup.com/locator/api.php?api="+api+"&city="+city+"&callback=?", function(j) { geoLocator_generateResultsOutput( j, 'city', city ) } ); } function geoLocator_zipSearch( api, zip, distance, kilo ) { jQuery.getJSON( "http://api.mppmarketinggroup.com/locator/api.php?api="+api+"&zip="+zip+"&distance="+distance+"&kilo="+kilo+"&callback=?", function(j) { geoLocator_generateResultsOutput( j, 'zip', zip ) } ); } function geoLocator_generateResultsOutput( data, type, query ) { var output = ""; if( type == "city" ) output = output + "We found " + data.totalResults + " locations in " + query.replace("~",", ") + ""; if( type == "zip" ) output = output + "We found " + data.totalResults + " locations within " + data.distance + "km of " + query + ""; if( type == "all" ) output = output + "We found " + data.totalResults + " locations to serve you"; for (var i = 0; i < data.results.length; i++) { output = output + '
'; output = output + '
'; output = output + data.results[i].address + '
'; output = output + data.results[i].city + ', ' + data.results[i].state + ', ' + data.results[i].zip + '
'; output = output + '
'; output = output + 'Tel: ' + data.results[i].phone + '
'; // START - Create a link to Google Maps: Dan @ Nov 26, 2009 for PizzaDepot // Replace spaces with +es var strReplaceAll = data.results[i].address + ' ' + data.results[i].city + ' ' + data.results[i].state; var intIndexOfMatch = strReplaceAll.indexOf( " " ); while (intIndexOfMatch != -1){ strReplaceAll = strReplaceAll.replace( " ", "+" ) intIndexOfMatch = strReplaceAll.indexOf( " " ); } output = output + 'Click here for an expanded map
'; // END if( data.results[i].distance != 0 ) output = output + 'Distance: ' + data.results[i].distance + 'km
'; output = output + '
'; //output = output + ''; output = output + '
'; } $('#loading').hide(); $('#results').show(); document.getElementById('results').innerHTML = output; for( var i = 0; i < data.results.length; i++ ) { loadMap( data.results[i].latitude, data.results[i].longitude, i ); } } function loadMap( lat, long, id ) { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("geoMap"+id)); var point = new GLatLng(lat,long); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(lat, long), 13); map.addOverlay(new GMarker(point)); } }