Hi,
I am Naresh is working on Googlemaps. I am extracting address of my
friends from the XML file and using the geocoder.getLocations() i am
able to pick the friends address but here I need address as well as
Name.
But I am not able to map the name & address into googlemap.
Here is the code which I created

<script type="text/javascript">

    var map;
    var geocoder;
    var strFname = "";
    var fn;
    var count = 0;

    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(17.3850440,78.4866710), 4);
      map.setUIToDefault();
      geocoder = new GClientGeocoder();
    }

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the
country code.
    function addAddressToMap(response)
    {
        if (!response || response.Status.code != 200)
        {
            // alert("Sorry, we were unable to geocode that address");
        }
        else
        {
            GDownloadUrl("data.xml", function(data, responseCode)
            {
                var xml = GXml.parse(data);
                var markers = xml.documentElement.getElementsByTagName
("friendname");

                fn = (markers[count].getAttribute("fname"));
            });
            count = count + 1 ;


            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],
            place.Point.coordinates[0]);

            // Create a base icon for all of our markers that
specifies the
            // shadow, icon dimensions, etc.
            var baseIcon = new GIcon(G_DEFAULT_ICON);
            baseIcon.shadow = "http://www.google.com/mapfiles/
shadow50.png";
            baseIcon.iconSize = new GSize(20, 34);
            baseIcon.shadowSize = new GSize(37, 34);
            baseIcon.iconAnchor = new GPoint(9, 34);
            baseIcon.infoWindowAnchor = new GPoint(9, 2);

            // Create a lettered icon for this point using our icon
class
            var letter = String.fromCharCode("A".charCodeAt(0) + 2);
            var letteredIcon = new GIcon(baseIcon);
            letteredIcon.image = "http://www.google.com/mapfiles/
marker" + letter + ".png";

            markerOptions = { icon:letteredIcon };
            var marker = new GMarker(point, markerOptions);
            map.addOverlay(marker);

            var information='<table border="0" width="200px"><tr><td
width="65px">'+ place.address +'</td></tr><tr><td width="65px">'+ fn
+'</td></tr></table>';
            GEvent.addListener(marker, "click", function() {

            marker.openInfoWindowHtml(information);

            });
        }
    }

    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation()
    {
        var address = document.forms[0].q.value;
        geocoder.getLocations(address, addAddressToMap);
    }

   // XML File code starts here
    GDownloadUrl("data.xml", function(data, responseCode)
    {
        var point = "";
        var xml = GXml.parse(data);
        var markers = xml.documentElement.getElementsByTagName
("friendname");



        for (var i=0; i<markers.length; i++)
        {
            point = (markers[i].getAttribute("address"));
            alert(point);
            fname = (markers[i].getAttribute("fname"));
            strFname=fname;
            // var latlon = savedata(point);
            // alert(latlon);

            geocoder.getLocations(point, addAddressToMap);
        }
    });
    // XML File code ends here

    </script>


    </head>
    <body onload="initialize()" onunload="GUnload()">
        <form action="#" onsubmit="showLocation(); return false;">
        </form>
        <div id="map_canvas" style="width: 500px; height: 300px"></
div>
    </body>
</html>


Please help me in this issue
Thanks in advance
With Regards,
Naresh Bonagiri

-- 
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