Classes
class TMap
TMap is the central class in the AJAX Maps API. All other classes in the API are used to alter the behaviour or state of this root class. Instantiate class TMap in order to create an instance of a map.
| Constructor | Description |
|---|---|
TMap(container:Element, options?:TMapOptions) |
Creates a new map inside of the given HTML container, which is typically a DIV element. |
Methods
Configuration
| Method | Return Value | Description |
|---|---|---|
| enableDoubleClickZoom(enable : Boolean) | None | Enable/Disable double click zoom in/out. Set by true/false. Default is true. |
| isDoubleClickZoomEnabled() | Boolean | Return true if double click zoom is enabled. |
| enableDragging(enable : Boolean) | None | Enable/Disable dragging map viewer. Default is true. |
| isDraggingEnabled() | Boolean | Return true if dragging map viewer is enabled. |
| enableScrollZoom(enable: Boolean) | None | Enable/Disable zoom in/out with mouse wheel. Set by true/false. Default is false. |
| isScrollZoomEnabled() | Boolean | Return true if the map viewer can zoom in/out with mouse wheel. |
| enableAnimation(isAnimationOn: Boolean) | None | Enable/Disable Animation of the map. Set by true/false. Default is true. |
| isAnimationEnabled() | Boolean | Return true if map animation is enabled. |
| enableContextMenu(enable: Boolean) | None | Enable/Disable ContextMenu. Set by true/false. Default is true. |
Controls
| Method | Return Value | Description |
|---|---|---|
| showSmallZoomBar(position?: TControlPosition) | None | Show the small zoom bar in the map viewer at the specified position. |
| hideSmallZoomBar() | None | Hide the small zoom bar in the map viewer. |
| showZoomBar(position?: TControlPosition) | None | Show the large zoom bar in the map viewer at the specified position. |
| hideZoomBar() | None | Hide the large zoom bar in the map viewer. |
| showScaleBar(position?: TControlPosition) | None | Show the scale bar in the map viewer at the specified position. |
| hideScaleBar() | None | Hide the scale bar in the map viewer. |
| showBirdView(position?: TControlPosition) | None | Show the bird view in the map viewer at the specified position. |
| hideBirdView() | None | Hide the bird view in the map viewer |
| addControl(control: TUserControl) | None | Add a user defined control into the map. |
| removeControl(control: TUserControl) | None | Remove the user defined control from the map. |
Overlays
| Method | Return Value | Description |
|---|---|---|
| addMarker(marker: TMarker) | None | Add a marker object into the map viewer. |
| removeMarker(marker:TMarker) | None | Remove the marker from the map viewer. |
| clearMarkers() | None | Remove all the markers from the map viewer. |
| getCurrentInfoWindow() | TInfoWindow | Get the current opened TInfoWindow object if it already exists. |
| openInfoWindow(position: TLatLon, htmlContent: String) | TInfoWindow | Open an new TInfoWindow at the specified position. |
| openInfoWindow(marker: TMarker, htmlContent: String) | TInfoWindow | Open an new TInforWindow and attach it to the specified TMarker. |
| closeInfoWindow() | None | Close the current opened TInfoWindow. |
| addGraphics(graphics : TGraphics) | None | Add TGraphics(TPolyline, TPolygon, TRect, etc.) object on map viewer. |
| removeGraphics(graphics : TGraphics) | None | Remove TGraphics object from map viewer. |
| clearGraphics() | None | Remove all the TGraphics objects from map viewer. |
Map State
| Method | Return Value | Description |
|---|---|---|
| getCenter() | TLatLon | Get the center coordinates of the map viewer. |
| getZoom() | Integer | Get the zoom level of the map viewer, value is 0-13. |
| getViewPort() | TViewPort | Returns viewport of current map viewer. |
Modify the Map State
| Method | Return Value | Description |
|---|---|---|
| setCenter(center:TLatLon) | None | Set the center coordinates of the map viewer. |
| setZoom(zoom : Integer) | None | Set the zoom level of the map viewer. |
| setViewPort(viewPort: TViewPort) |
None |
Set the viewport to map. |
| zoomIn() | None | Zoom in by one zoom level. |
| zoomOut() | None | Zoom out by one zoom level. |
| zoomToFit(points: Array<TLatLon>) | None | Zoom to fit all points specified in the same zoom level. |
| zoomToFit(points: Array<TGraphics | TMarker>) | None | Zoom to fit all TGraphics(TPolyline, TPolygon, TRect, etc.) or TMarker specified in the same zoom level. |
| zoomByBound(leftTop: TLatLon, rightBottom: TLatLon, isZoomIn?: Boolean ) |
None | Zoom in/out the map by bound rect. If isZoomIn is not given, the result is the same the zoomToFit function. |
| setContextMenu(contextMenu: TContextMenu) | None | Set context menu to map. |
| setCursor(cursor: String) | None | Set cursor by specifying cursor format image URL. |
| resetCursor() | None | Restore to the default cursor. |
| setSize(width: Integer, height: Integer) | None | Set the size of map viewer. Note: The container's size would also be changed as the specified size. |
| updateSize() | None | Update size of map viewer. Note: The map viewer would always fill up the container's view. Once the container's size changed, this method should be invoked. |
| showAll() | None | Show the map viewer within the container. When initialize the map, you need to call showAll() function to finish the initialization. |
Events
| Event | Description |
|---|---|
| dragstart(tmap:TMap) | This event is fired when the user starts dragging the map. |
| drag(tmap: TMap) | This event is fired repeatedly while the user drags the map. |
| dragend(tmap: TMap) | This event is fired when the user stops dragging the map. |
| center(tmap: TMap, position:TLatLon, zoom:Integer) | The center or zoom of the map was changed. |
| click(tmap: TMap, position:TLatLon) | The mouse left click in the map. |
| doubleclick(tmap: TMap, position:TLatLon) | The mouse double click in the map. |