Hi All, I've put together a store locator using the standard outlined example, but would like it to pull information from 2 more column in my SQL table. I'm not massively au fait with coding, so this has thrown me completely, as outwardly I have zero idea why what I have done is not working:
************************************************************************************************** <br/><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/ > <title>Savant Store Locator</title> <script src="http://maps.google.com/maps? file=api&v=2&key=ABQIAAAASq- LcmIfW8Q4KGCJgFSb4RT6LZ7kIYZaKoX50xVAx8p5LpkADBRhloxt4ss39LpZehN5CYJeZnlWtg" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ var map; var geocoder; function load() { if (GBrowserIsCompatible()) { geocoder = new GClientGeocoder(); map = new GMap2(document.getElementById('map')); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(55, -4), 5); } } function searchLocations() { var address = document.getElementById('addressInput').value; geocoder.getLatLng(address, function(latlng) { if (!latlng) { alert(address + ' not found'); } else { searchLocationsNear(latlng); } }); } function searchLocationsNear(center) { var radius = document.getElementById('radiusSelect').value; var searchUrl = 'phpsqlsearch_genxml.php?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius; GDownloadUrl(searchUrl, function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName ('marker'); map.clearOverlays(); var sidebar = document.getElementById('sidebar'); sidebar.innerHTML = ''; if (markers.length == 0) { sidebar.innerHTML = 'No results found.'; map.setCenter(new GLatLng(55, -4), 5); return; } var bounds = new GLatLngBounds(); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute('name'); var address = markers[i].getAttribute('address'); <!-- These are the extra fields --> var type = markers[i].getAttribute('type'); var phone = markers[i].getAttribute('phone'); var distance = parseFloat(markers[i].getAttribute ('distance')); var point = new GLatLng(parseFloat(markers[i].getAttribute ('lat')), parseFloat(markers[i].getAttribute ('lng'))); var marker = createMarker(point, name, address, type, phone); map.addOverlay(marker); var sidebarEntry = createSidebarEntry(marker, name, distance); sidebar.appendChild(sidebarEntry); bounds.extend(point); } map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel (bounds)); }); } <!-- This is where the extra fields should be called up --> function createMarker(point, name, address, type, phone) { var marker = new GMarker(point); <!-- The formatting here works, but just returns null --> var html = '<b>' + name + '</b> <br/>' + address + '<br/><b>' + type + '</b> <br/>' + phone; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } function createSidebarEntry(marker, name, distance) { var div = document.createElement('div'); var html = '<b>' + name + '</b> (' + distance.toFixed(1) + ' miles)<br/>'; div.innerHTML = html; div.style.cursor = 'pointer'; div.style.marginBottom = '5px'; GEvent.addDomListener(div, 'click', function() { GEvent.trigger(marker, 'click'); }); GEvent.addDomListener(div, 'mouseover', function() { div.style.backgroundColor = '#eee'; }); GEvent.addDomListener(div, 'mouseout', function() { div.style.backgroundColor = '#fff'; }); return div; } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <p>If you need your product in a hurry, and would like to find a local stockist, please use the search function below. We recommend that you phone ahead to make sure that the store has stock.</p> <p>Address/Post Code: <input type="text" id="addressInput"/> Radius (miles): <select id="radiusSelect"> <option value="5" selected>5</option> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> </select> <input type="button" onclick="searchLocations()" value="Search Locations"/> <br/> <br/> </p> <div style="width:600px; font-family:Arial, sans-serif; font-size:11px; border:1px solid black"> <table> <tbody> <tr> <td width="200" valign="top"> <div id="sidebar" style="overflow: auto; height: 400px; font-size: 11px; color: #000"></ div> </td> <td> <div id="map" style="overflow: hidden; width:400px; height:400px"></div> </td> </tr> </tbody> </table> </div> </body> </html> ************************************************************************************************** It's all reaonably standard, but should also call data from the columns type and phone, the idea being that the type of store is then displayed beneath the address, and the phone number beneath that. However, it just returns "null" for both columns. I've copied the settings for the name field in the SQL table for both type and phone, and checked this worked by switching column names around, at which point it did bring in the data from the columns it had previously ignored. Is the script somehow coded to only be able to pull up data that it was originally designed for?! Am I missing something terribly obvious? Put simply this has completely done my head in! Any help greatly appreciated Tony --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" 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-API?hl=en -~----------~----~----~----~------~----~------~--~---
