Hi, from Google examples I have written code to:

1. Retrieve address data from database & convert to xml
2. use geocoder.getLatLng to geocode the address string
3. Place markers on a Google map

I have now have an issue where my markers do not pull the correct data
for "name", "address type", etc.... It uses one value for all.

Here is my working link:

http://31st.com/google-maps/google-geocode.html

Here is my code:

                function showAddress(address) {
                if (GBrowserIsCompatible()) {

                var map = new GMap2(document.getElementById("map"));
        geocoder = new GClientGeocoder();
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(36.16693,-86.784439), 12);

          GDownloadUrl("gen_xml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName
("marker");

                  for (var i = 0; i < markers.length; i++) {
            var address = markers[i].getAttribute("address");
            var type = markers[i].getAttribute("type");
                        var name = markers[i].getAttribute("name");

                                geocoder.getLatLng( //HERE IS WHERE I BELIEVE 
THE PROBLEM BEGINS
                                address,
                                function(point) {
                                  if (!point) {
                                        alert(address + " not found");
                                  } else {

                                        var marker = createMarker(point, name, 
address, type);
                                        map.addOverlay(marker);

                                  }
                                }
                          );
                         }

          });

        }}

                                  function createMarker(point, name, address, 
type) {
                                  var marker = new GMarker(point);
                                  var html = "<b>" + name + "</b> <br/>" + 
address + "<br/>" +
point;
                                  GEvent.addListener(marker, 'click', 
function() {
                                        marker.openInfoWindowHtml(html);
                                  });
                                  return marker;
                                }

--

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.


Reply via email to