SD Maps API Reference

Table of Contents:


Map Class
Constructor Description
Map (dom, options) Create a new map inside of the given HTML container, which is typically a DIV element.

Properties Type Description
zoom number Map zoom level. Default zoom level is 1.
center LngLat Map center position (in geo).
draggable boolean Enable / disable dragging of the map. Enable by default.
enableDefaultLogo boolean Enable / disable default SD.com logo on the map. Enable by default.
showCopyright boolean Enable / disable default copyright text on the map. Enable by default.
resize WidthHeight Resize size of the map in specific width and height.
size WidthHeight Map size (in pixels).
viewport object Instance of ViewportControl.
viewportInfo object Instance of viewportInfo, detail information of map can be access from here.
canvasInfo object Clone of viewportInfo, detail information of map can be access from here.
infoWindow object Instance of SD.genmap.GInfoWindow.

Methods Return Value Description
refresh () none Rendering map and all layers.
setDragging (boolean) none Enable / disable dragging of the map.
fromLatLngToContainerPixel (geo) pixels Computes the pixel coordinates of the given geographical point.
fromContainerPixelToLatLng (pixels) LngLat Computes the geographical coordinates of the given pixel point.
setZoom (zoom, refresh) none Set zoom level of the map.
getDom () dom Get dom information.
setCenter (geo, zoom) none Set center position and zoom level of the map.
getCenter () LngLat Get center of the map (in geo).
setInfoWindow (info) none Set infoWindow.
panBy (x, y) none Change the center of the map by the given distance in pixels.
If the change is less than both the width and height of the map, the transitions will be smoothly animated.
panTo (geo) none Change the center of the map by the given distance in geo.
If the change is less than both the width and height of the map, the transitions will be smoothly animated.
resizeViewport (width, height) none Resize size of the map in pixels.
getBounds () LngLatBounds Get the LngLat bounds of the current viewpoint.
If the map is not initialized yet the result is false.
addControl (navigation) none Add control to the map. A control instance must not be added more than once to the map.
Available navigation: MediumMapControl(), CompleteMapControl(), and DrawingMapControl().
addLogo (pathImg, size, position, targetUrl) none Add logo on the map.



Event Manager Class
Constructor Description
EventManager.init () Event manager is initialization when methods EventManager.add is called.

Properties Type Description
last_lable number Return last lable from event manager.

Methods Return Value Description
EventManager.add (object, eventType, method, [lable]) lable Add Event on the map.
EventManager.remove(lable, [forceDel]) boolean Remove selected event on the map.
EventManager.unloadEvents () none Remove all events.



Marker - Marker Image
Constructor Description
MarkerImage () MarkerImage is initialization when methods MarkerStatic is called.

Properties Type Description
Image string Image path for the icon.
title string Title for the icon.
pt LeftTop Position of the icon (in pixels).
iconSize WidthHeight Set size for the icon.
iconAnchor LeftTop Set position of the icon from the marker position.
infoWindowAnchor LeftTop Set position of the infoWindow from the marker position.

Methods Return Value Description
getObject (zIndex) dom Get dom information about the icon. Can insert zIndex via parameter.
setIndex (zIndex) none Set z-index for the icon.
setImage (src) none Set image source of the icon.
setPoint (position) none Set position of the icon.
setOffset (offset) none Set offset of the icon.
getPosition () pixels Get position of the icon in pixels.
setPosition (pixels) none Set position of the icon in pixels.
setDisplay (condition) none Show / hide the icon.

Marker - Marker Static Manager
Constructor Description
MarkerStaticManager (options) Create a new marker static manager on the map.

Properties Type Description
map dom Map which to display the marker.
projection string Projection of MarkerStatic.

Methods Return Value Description
add (options) marker Add new MarkerStatic on the map.
remove (marker) none Remove selected MarkerStatic on the map.
clear () none Remove all MarkerStatic.
setAutoAdjust (points) none Auto zoom map to the best level to fit all markers drawn inside the map.

Marker - Marker Static
Constructor Description
MarkerStatic () MarkerStatic is initialization when methods MarkerStaticManager.add is called.

Properties Type Description
map dom Map which to display the marker.
icon object Instance of SD.genmap.MarkerImage, class for handle object image.
position LngLat / vertex Position of the marker (can be in geo / vertex).
positionPt Pixels Position of the marker (in pixels).
projection string Projection of MarkerStatic.
draggable boolean Enable / disable dragging of the marker.
visible boolean The marker status (show / hide).
hideOnLevel array Hide marker on the given level.
zIndex number Set level of z-index of the marker.
div dom Dom information about div marker.
title string If marker title isn't set in MarkerImage, then use this title.
enable boolean The marker status (enable / disable).

Methods Return Value Description
replaceIcon (icon) none Replace old icon with new one.
getDom () dom Get dom object of MarkerStatic.
getPtPosition () pixels Get position of MarkerStatic in pixels.
getSize () pixels Get size of the MarkerStatic.
updatePosition (ViewportInfo) none Update position of MarkerStatic.
setPosition (position) none Set position of the MarkerStatic, can be in geo or vertex.
setOffset (offset, scale) none Set offset, so this offset will calculated with current position.
draw (ViewportInfo) none Draw MarketStatic.
setEnable (condition) boolean Enable / disable this StaticMarker.
setDisplay (condition) boolean Show / hide the StaticMarker.

Marker - infoWindow
Constructor Description
SD.genmap.GInfoWindow () MarkerStatic is initialization when methods map is created.

Properties Type Description
marker object Marker where to put the infoWindow.
content string Content of infoWindow.
visible boolean InfoWindow visible status.
size WidthHeight Size of infoWindow.
minSize WidthHeight Minimal size of infoWindow.
div dom Dom information about infoWindow.
enable boolean InfoWindow visible status.

Methods Return Value Description
open (marker, content) none Open an infoWindow.
close () none Close an infoWindow.
setSize (width, height) none Set size for infoWindow.



Viewport Control
Constructor Description
ViewportControl() ViewportInfo is initialization when map is created.

Properties Type Description
OnLevelChanged object Instance of EventDelegates. Triggered if zoom level changes (by scroll and by zoom control click).
OnDraw object Instance of EventDelegates. Triggered if map is being draw,
OnEndDrag object Instance of EventDelegates. Triggered if map is panned using mouse.
OnEndMove object Instance of EventDelegates. Triggered if map is panned using directional control.

Methods Return Value Description
getCenter (offset) meter Get center of the offset given (in meter).
setCenter (geo, refresh) none Set center position of the map.
getCenterOnWorldBound (newCenter) LngLat Get center position.
zoomIn () none Zoom in the map.
zoomOut () none Zoom out the map.
getInfo () object Viewport information.
draw () none Draw all map layer.
clearMap () none Clear map layer.
getCursorDistanceFromCenter () pixels Cursor position from center in pixels.
animatePanBy (pos, step) none Change the center of the map by the given distance in pixels.
animatePanTo (Geo, step) none Change the center of the map by the given distance in geo.
setLogoToDefault () none Set logo to default logo.
resize (w, h, isDraw) none Resize viewport.

Viewport Info
Constructor Description
ViewportInfo() ViewportInfo is initialization when map is created.

Properties Type Description
div dom Dom information about div viewportInfo.
scale number Ratio of a distance on the map to the corresponding distance on the ground.
levelIndex number Map zoom level.
lastCursorLatLon LngLat Last position of cursor (in geo).
lastCursorPosDown pixels Last position of cursor when mouse down (in pixels).
lastCursorPosUp pixels Position of cursor when mouse up (in pixels).
lastCursorPosMove pixels Position of cursor when mouse move (in pixels).
lastCursorPosOffset number Offset position of cursor.
projection object Instance of projection, detail information of projection can be access from here.
canvasSize WidthHeight Canvas size.
centerGeo LngLat Center of map (in geo).
centerMetric meter Center of map (in meter).
centerScreen pixels Center of map (in pixels).
topLeftGeo LngLat Top Left map position (in geo).
topLeftMetric meter Top Left map position (in meter).
topLeftScreen pixels Top Left map position (in pixels).
screenView pixels Map rectangle information (in pixels).
metricView meter Map rectangle information (in meter).
geoView geo Map rectangle information (in geo).

Methods Return Value Description
recalculate () none Recalculate all viewport.
getCanvasRect () pixels Get canvas rectangular position.
getCanvasSize () WidthHeight Get canvas size.
viewportScreenToGeo (x,y) LngLat Convert from screen viewport to geo.
viewportGeoToScreen (geo) pixels Convert from geo viewport to screen.
viewportScreenToMetric (x,y) meter Convert from screen viewport to vertex.
canvasGeoToScreen (geo) pixels Convert from geo viewport to canvas.
setCenterFromViewportScreenPosition (x, y) none Set center from viewport screen position.
viewportScale (param) number If param set, than set viewport scale. If not, return viewport current scale.
setCenter (offsetX, offsetY) none Set viewport center.
getMetricPosDown () meter Get vertex position.
getMetricPosMove () meter Get vertex position.



Projection
Constructor Description
SD.projection.Default() Create new default projection.

Properties Type Description
rMajor number
rMinor number
temp number
M_PI_2 number Half of phi.
eccent number
eccenth number
name string Map projection name.

Methods Return Value Description
radToDeg (ang) number Convert from rad to deg.
degToRad (ang) number Convert from deg to rad.
mercX (lon) number Conver from lon to mercantor x.
unMercX (x) lon Conver from mercantor x to lon.
geoToMetric (longitude, latitude) vertex Convert from geo to mercantor.
metricToGeo (x, y) geo Convert from mercantor to geo.
unMercY (y) lat Convert from mercantor y to lat.
mercY (lat) vertex Convert from lat to mercator y.
geoToScreen (lon, lat, scale, topLeft) pixels Conver from geo to screen.
screenToGeo (x, y, scale, topLeft) geo Convert from screen to geo.
metricToScreen (x, y, scale, topLeft) pixels Convert from vertex to screen.
screenToMetric (x, y, scale, topLeft) vertex Convert from screen to vertex.
geoToPixel (lon, lat, scale) pixels Convert from geo to pixels.
pixelToGeo (x, y, scale) LngLat Convert from pixels to geo.
inflateGeo (centerGeo, x, y, scale)
inflateVert (center, x, y, scale)
metricToPixel (x, y, scale) pixels Convert from vertex to pixels.
pixelToMetric (x, y, scale) vertex Convert from pixels to vertex.



Polyline / Polygon Manager
Constructor Description
SD.genmap.PolylineManager(options) Create a polyline / polygon manager.

Properties Type Description
map dom Map which to display the polyline / polygon.
projection string Projection of polyline / polygon manager.
node object Polyline / polygon list.

Methods Return Value Description
add (nodes, options) Polyline / polygon object Add polyline / polygon object
remove (p) none Remove polyline / polygon object

Polyline / Polygon
Constructor Description
SD.shape.Polyline(nodes, options) Polyline / polygon is created when using add method in SD.genmap.PolylineManager.

Properties Type Description
arrowOption object Polyline / polygon arrowOption.
color color code Polyline / polygon arrow color.
size number Polyline / polygon arrow size.
bgColor color code Polyline / polygon background color.
boundGeo bounds Polyline / polygon bounds in geo.
boundMetric bounds Polyline / polygon bounds in metric.
boundScreen bounds Polyline / polygon bounds in pixel.
bounds bounds Polyline / polygon bounds.
centerGeo LngLat Polyline / polygon center position in geo.
centerMetric metric Polyline / polygon center position in metric.
color color code Polyline / polygon color.
div dom Polyline / polygon dom.
enable boolean Polyline / polygon enable status.
fillOpacity number Polyline / polygon opacity.
hideOnLevel array Polyline / polygon hide on level.
index number Polyline / polygon index.
points list point Polyline / polygon point list.
scale number Polyline / polygon scale.
size number Polyline / polygon line size.

Methods Return Value Description
setPoints(point) none Set polyline / polygon point.
setOptions(options) none Reset polyline / polygon options.



SDServiceXml
Constructor Description
SDServiceXml(url, map) Create new layer, based on xml/kml data retreived from the url.

Below is the simple example of using SDServiceXml object.
<html>

<head>

<script type="text/javascript" language="JavaScript" src="http://www.streetdirectory.com/js/map_api/m.php"></script> 

<script type="text/javascript">

    function initialize() {
    
        var latlng = new GeoPoint(106.536160800000005,-6.206499064007618);
        
        var myOptions = {
        
            zoom: 6,
            
            center: latlng,
            
            enableDefaultLogo: false
        
        };
        
        var map = new SD.genmap.Map(
        
            document.getElementById("map_canvas"), 
            
            myOptions
        
        );
		
	var service = new SDServiceXml("http://www.streetdirectory.com/api/developer/docs/examples/tol.kml", map);
    
    }

</script>

</head>

<body onload="initialize()">

    <div id="map_canvas" style="width:100%; height:100%"></div>

</body>

</html>