GetAddressByLatLng

This function provides a convenient way to reverse geocode the given geographical location to address (See TAddress for reference), i.e. it takes geographical location as the input and gets us a description of address. Sends a request to TerraFly® servers to reverse geocode the specified geographical location. If the geographical location was successfully reverse geocoded, the user-specified callback function ReverseGeoCode is invoked and the arguments conveyed to the callback function is the closest address for the point. Otherwise, the callback function is given a string of “No streets found”.
public TGetAddressByLatLng(lat, lng, CallBackFunctor):Void

Parameters

  • lat : Number - Specify the latitude of the given geographical location to be reversed to address.
  • lng : Number - Specify the logitude of the given geographical location to be reversed to address.
  • GeocodeCallBackFunctor : Functor Object - This function is called if the address is successfully located.The arguments conveyed to the callback function is the nearest address from the given geographical location.
  • Returns

  • Void
  • Example

    The following example shows how to get address by latitude and longitude.
    <div id="mapContainer"  style="width: 640px; height: 400px;"></div>
    <script type="text/javascript">
        var map0 = new TMap(mapContainer, 25.7590256665386, -80.3738769902151, 15, Load, 1, true, "", "hybrid");
       
       function Load() {
    	    map0.SetPanelVisibility("NAV", "SHOW");
                map0.SetPanelVisibility("ZOOM", "SHOW");
                map0.SetPanelVisibility("OVERVIEW", "SHOW");
            }
       function Button_Goto_onclick(){
                var lat = latitude.value;
                var lng = longitudt.value;
                TGetAddressByLatLng(lat, lng, geoCodeReverse);
            }
     
       function geoCodeReverse(Address){
                if ( Address == 0.0){
                    alert("Could not find the location!");
                }
                else {
                    TextArea.value+= Address;
                }
            }       
    </script>
        

    See also

  • TGetLatLngByAddress()

    See example

    Terrafly Geocoding reverse service