SD Maps Reverse Geocode

Reverse Geocode

We provide a wrapper from our SDGeocode class to call our Reverse Geocode service.

Currently you have to specify the region to search for. These are the supported values:

Below is example of reverse-geocoding request. Only 1 unique result will be returned.
var geocode = new SDGeocode(map);

// your function
function rGeocode(x,y){
    $("#longlat").html( x + "," + y);
    geocode.reverse(SDGeocode.SG, {x:x, y:y});
}

// you should define function set_data()
function set_data(json) {
    
    if (json.length == 0) return;
    var rec = json[0];
    mm.clear();
    
    if (rec.x && rec.y) {
        var icon = new SD.genmap.MarkerImage({
            image : "img/openrice_icon.png",
            title : rec.t,
            iconSize : new Size(15, 15),
            iconAnchor : new Point(7, 15),
            infoWindowAnchor : new Point(5, 0)
        });
        
        var geo = new GeoPoint(parseFloat(rec.x), parseFloat(rec.y));
        map.setCenter(geo, map.zoom);
        var marker = mm.add({
            position: geo,
            map: map,
            icon: icon
        });
        
        map.infoWindow.open(marker, rec.a  + rec.x + " - " + rec.y );
    }
}
Parameters Description
ctype data type to be returned
1 = location
2 = business
If not specified, API will return both types
x current position - longitude required
y current position - latitude required
dist radius (in km) optional (default is 1km)
d 1 = display detailed info  

Response :

Attributes Description  
t place/company name or title  
a full address  
x position - longitude/x-vertex (depends on the request)  
y position - latitude/y-vertex (depends on the request)  
u URL reference to Streetdirectory  
these attributes below will be returned when param d=1 is specified
aid SD address ID  
pid SD place ID  
pc postal code  
dt data type  
pcn place name  
st_na street name  
blk_no block number  
u_no unit number  
Note: x & y attribute will always be provided in the API response. The other attributes might not be provided.
We suggest you to add a safety/null check before processing it.

js - You should have set_data() function defined on your side
set_data([
    {
        "t":"Far East Shopping Centre",
        "a":"545 Orchard Road, 238882",
        "x":"103.82977505",
        "y":"1.3056830304",												  
        "u":"http:\/\/www.streetdirectory.com\/asia_travel\/travel\/travel_id_1\/travel_site_22925\/"}
    }
]);