Hi, I'm trying to use the geocoder to return the lat long values from
an address on a MySQL database.

I'm using two sources of code here, both from Google. The first was a
v2 article on how to work with MySQL databases (use PHP to echo XML).
Located here http://code.google.com/apis/maps/articles/phpsqlajax.html

The second was this, just a simple geocoding example.
http://code.google.com/apis/maps/documentation/javascript/v2/examples/geocoding-simple.html

I've tried to sort of merge them together as you can see.

I'd really appreciate any help you can give, I've been trying to fix
this for ages and just cant. I'm reasonably new to both JavaScript and
the Google Maps API's, so any responses would be greatly appreciated
as if you were talking to an idiot :)

Thank you very much in advance.

function load() {
      if (GBrowserIsCompatible()) {

        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(52.2725, -0.8825), 12);

        GDownloadUrl("phpsqlajax_genxml3.php", function(data) {
          var xml = GXml.parse(data);
          var markers =
xml.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var id = markers[i].getAttribute("ID");
            var address = markers[i].getAttribute("ADDRESS");
            var image = markers[i].getAttribute("IMAGE");
            var point = showAddress(address);
            alert(address);
            var marker = createMarker(point, id, address, image);
            map.addOverlay(marker);
          }
        });
      }
    }

 function showAddress(address) {

    var address2 = geocoder.getLatLng(address);
      //if (geocoder) {
        //geocoder.getLatLng(address);
      //}
      return address2;
    }

    function createMarker(point, id, address, image) {
      var marker = new GMarker(point);
      var html = "<b>" + id + "</b> <br/>" + address;
      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 V2" 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