How to get address from Latitude/Longitude?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SwapnilD
    New Member
    • Jan 2010
    • 41

    How to get address from Latitude/Longitude?

    I'm passing Multiple Lat/lan parameters to GOOGLE map to generate a MAP and also showing markers for all the locations based upon Lat/Lng.

    on mouseover event of Marker I'm showing pop up with some info, but along with the info I would also like to show the addrees based upon the lat/lng.

    Below is the snippet of code which displays a popup on hover of markers ...

    Code:
    var map = new GMap2(document.getElementById("map_canvas"));
    
    //Iterate for all the pairs of Latitude/Longitude values
    for (i=0; i < LatLang.length; i++) 
    {
       count = count + 1;
       
       //Assign Lat/Lang to array
       AddrLatLang = LatLang[i].split(",");
       
       point = new GLatLng(AddrLatLang [0],AddrLatLang [1]);
        
       // Call to ShowMarker function
       ShowMarker(point,map,UID,Uname,Dates[i],Times[i])
        
    }
    
    function ShowMarker(Point,map,UID,Uname,LDate,LTime)
    {
        var marker = new GMarker(Point);
        var image = G_DEFAULT_ICON.image;
        
        var htmlText = "<span style='Font-Family: Verdana; Font-Size: 12px;'><center>"
            htmlText += "<b>VIN: " + UID+ "</b></center></span></br>";
            htmlText += "<b>Debtor: " + Uname+ "</b></center></span></br>";
            htmlText += "<b>Locate Date: " + LDate + "</b></center></span></br>";
            htmlText += "<b>Locate Time: " + LTime + "</b></center></span></br>";
            htmlText += "<b>Address: " + "Here I want to show ADDRESS" + "</b></center></span>";
    	
        GEvent.addListener(marker, 'mouseover', function() {
        marker.openInfoWindowHtml(htmlText);
        });
    
        GEvent.addListener(marker, 'mouseout', function() {
        marker.closeInfoWindow();
        });
        setTimeout(function() {marker.setImage(image)},0);
    }
    I found below link which displays address on click of map but it is not useful in my case, I just want to retrieve address form lat/lang parameters and assign this address to simple string variable.

    // Below link displays marker with popup info when map is clicked...
    http://code.google.com/apis/maps/documentation/javascript/v2/examples/geocoding-reverse.html

    Thanks in advance,

    Swapnil
Working...