SD Maps Geocode

Simple Geocode

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

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

Below is example of simple geocode usage.
var geocode = new SDGeocode(map);

// your function
function search(keyword) {
    var searchOption = {"q": keyword};
    var gc = SDGeocode.SG;
    geocode.requestData(gc, searchOption);

// you should define function set_data()
function set_data(json) {
    for (var i=0; i< json.length; i++) {
        var rec = json[i];
        if (rec.x && rec.y) {
            var icon = new SD.genmap.MarkerImage({
                image: SD.BASE_URL + "img/openrice_icon.png",
                title: rec.t,
                iconSize: new Size(15,15),
                iconAnchor: new Point(7,15),
                infoWindowAnchor: new Point(5,0)
            mm = new SD.genmap.MarkerStaticManager({ map:map });			
            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 
            var ctn = "<strong><a href='" + rec.u + "' target='_blank'>" + rec.t + "<</a>" + "</strong><br>" + rec.a;
            assignClickEvent(trow, marker, rec);

Alternatively, if you want to specify other parameters you can do:

var searchOption = {"q": keyword, "d": 1};
geocode.requestData(gc, searchOption);
Parameters Description
ctype data type to be returned
1 = location
2 = business
If not specified, API will return both types
start start index optional
limit total result returned optional (default is 20)
q keyword to search
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
        "t":"Far East Shopping Centre",
        "a":"545 Orchard Road, 238882",
        "t":"ATM, Orchard Road (UOB)",
        "a":"545 Orchard Road, 238882",