Class: Map

Map

The central class of the library, to create a map on a container.

new Map(container, options) [source]

var map = new maptalks.Map("map",{
     center:     [180,0],
     zoom:  4,
     baseLayer : new maptalks.TileLayer("base",{
         urlTemplate:'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
         subdomains:['a','b','c']
     }),
     layers : [
         new maptalks.VectorLayer('v', [new maptalks.Marker([180, 0])])
     ]
});
Parameter Type Description
container string | HTMLElement | object The container to create the map on, can be:
1. A HTMLElement container.
2. ID of a HTMLElement container.
3. Any canvas compatible container
options Object construct options
Properties
Parameter Type Default Description
center Array.<Number> | Coordinate initial center of the map.
zoom Number initial zoom of the map.
spatialReference opt Object null map's spatial reference, default is using projection EPSG:3857 with resolutions used by google map/osm.
baseLayer opt Layer null base layer that will be set to map initially.
layers opt Array.<Layer> null layers that will be added to map initially.
* * any other option defined in Map.options [description]
Extends:
Mixes From:
Fires:

Members

  • (constant) options

  • Properties:
    Name Type Description
    options Object map's options, options must be updated by config method:
    map.config('zoomAnimation', false);
    Properties
    Name Type Default Description
    centerCross opt Boolean false Display a red cross in the center of map
    zoomInCenter opt Boolean false whether to fix in the center when zooming
    zoomAnimation opt Boolean true enable zooming animation
    zoomAnimationDuration opt Number 330 zoom animation duration.
    panAnimation opt Boolean true continue to animate panning when draging or touching ended.
    panAnimationDuration opt Boolean 600 duration of pan animation.
    zoomable opt Boolean true whether to enable map zooming.
    enableInfoWindow opt Boolean true whether to enable infowindow on this map.
    hitDetect opt Boolean true whether to enable hit detecting of layers for cursor style on this map, disable it to improve performance.
    hitDetectLimit opt Boolean 5 the maximum number of layers to perform hit detect.
    fpsOnInteracting opt Boolean 25 fps when map is interacting, some slow layers will not be drawn on interacting when fps is low. Set to 0 to disable it.
    layerCanvasLimitOnInteracting opt Boolean -1 limit of layer canvas to draw on map when interacting, set it to improve perf.
    maxZoom opt Number null the maximum zoom the map can be zooming to.
    minZoom opt Number null the minimum zoom the map can be zooming to.
    maxExtent opt Extent null when maxExtent is set, map will be restricted to the give max extent and bouncing back when user trying to pan ouside the extent.
    fixCenterOnResize opt Boolean false whether to fix map center when map is resized
    maxPitch opt Number 80 max pitch
    maxVisualPitch opt Number 60 the max pitch to be visual
    viewHistory opt Extent true whether to record view history
    viewHistoryCount opt Extent 10 the count of view history record.
    draggable opt Boolean true disable the map dragging if set to false.
    dragPan opt Boolean true if true, map can be dragged to pan.
    dragRotate opt Boolean true default true. If true, map can be dragged to rotate by right click or ctrl + left click.
    dragPitch opt Boolean true default true. If true, map can be dragged to pitch by right click or ctrl + left click.
    dragRotatePitch opt Boolean true if true, map is dragged to pitch and rotate at the same time.
    touchGesture opt Boolean true whether to allow map to zoom/rotate/tilt by two finger touch gestures.
    touchZoom opt Boolean true whether to allow map to zoom by touch pinch.
    touchRotate opt Boolean true whether to allow map to rotate by touch pinch.
    touchPitch opt Boolean true whether to allow map to pitch by touch pinch.
    touchZoomRotate opt Boolean false if true, map is to zoom and rotate at the same time by touch pinch.
    doubleClickZoom opt Boolean true whether to allow map to zoom by double click events.
    scrollWheelZoom opt Boolean true whether to allow map to zoom by scroll wheel events.
    geometryEvents opt Boolean true enable/disable firing geometry events
    control opt Boolean true whether allow map to add controls.
    attribution opt Boolean | Object true whether to display the attribution control on the map. if true, attribution display maptalks info; if object, you can specify positon or your base content, and both;
    zoomControl opt Boolean | Object false display the zoom control on the map if set to true or a object as the control construct option.
    scaleControl opt Boolean | Object false display the scale control on the map if set to true or a object as the control construct option.
    overviewControl opt Boolean | Object false display the overview control on the map if set to true or a object as the control construct option.
    fog opt Boolean true whether to draw fog in far distance.
    fogColor opt Array.<Number> [233, 233, 233] color of fog: [r, g, b]
    renderer opt String canvas renderer type. Don't change it if you are not sure about it. About renderer, see TODO.
    Source:

  • (constant) JSON_VERSION

  • Properties:
    Type Description
    String Version of the JSON schema.
    Source:

    Static Methods

  • (protected, static) addOnLoadHook(fn) [source]

  • Add hooks for additional codes when map's loading complete, useful for plugin developping.
    Parameter Type Description
    fn function
    Returns:
    Map:
  • (static) fromJSON(container, mapJSON, optionsopt) [source]

  • Reproduce a map from map's profile JSON.
    var map = Map.fromJSON('map', mapProfile);
    Parameter Type Default Description
    container string | HTMLElement | object The container to create the map on, can be:
    1. A HTMLElement container.
    2. ID of a HTMLElement container.
    3. A canvas compatible container in node, e.g. node-canvas, canvas2svg
    mapJSON Object map's profile JSON
    options opt Object null options
    Properties
    Parameter Type Default Description
    baseLayer opt Object null whether to import the baseLayer
    layers opt Object null whether to import the layers
    Returns:
    Map:

    Methods

  • isLoaded() [source]

  • Whether the map is loaded or not.
    Returns:
    Boolean:
  • getContainer() [source]

  • Get map's container
    Returns:
    HTMLElement:
  • getSpatialReference() [source]

  • Get the spatial reference of the Map.
    Returns:
    SpatialReference: map's spatial reference
  • setSpatialReference(spatialReference) [source]

  • Change the spatial reference of the map.
    A SpatialReference is a series of settings to decide the map presentation:
    1. the projection.
    2. zoom levels and resolutions.
    3. full extent.
    There are some predefined spatial references, and surely you can define a custom one..
    SpatialReference can also be updated by map.config('spatialReference', spatialReference);
    map.setSpatialReference({
                projection:'EPSG:4326',
                resolutions: (function() {
                    const resolutions = [];
                    for (let i=0; i < 19; i++) {
                        resolutions[i] = 180/(Math.pow(2, i)*128);
                    }
                    return resolutions;
                })()
     });
           
    map.config('spatialReference', {
                projection:'EPSG:4326',
                resolutions: (function() {
                    const resolutions = [];
                    for (let i=0; i < 19; i++) {
                        resolutions[i] = 180/(Math.pow(2, i)*128);
                    }
                    return resolutions;
                })()
            });
    Parameter Type Description
    spatialReference SpatialReference spatial reference
    Fires:
    Returns:
    Map: this
  • getProjection() [source]

  • Get the projection of the map.
    Projection is an algorithm for map projection, e.g. well-known Mercator Projection
    A projection must have 2 methods:
    1. project(coordinate) - project the input coordinate
    2. unproject(coordinate) - unproject the input coordinate
    Projection also contains measuring method usually extended from a measurer:
    1. measureLength(coord1, coord2) - compute length between 2 coordinates.
    2. measureArea(coords[]) - compute area of the input coordinates.
    3. locate(coord, distx, disty) - compute the coordinate from the coord with xdist on axis x and ydist on axis y.
    Returns:
    Object:
  • getFullExtent() [source]

  • Get map's full extent, which is defined in map's spatial reference.
    eg: {'left': -180, 'right' : 180, 'top' : 90, 'bottom' : -90}
    Returns:
    Extent:
  • setCursor(cursor) [source]

  • Set map's cursor style, cursor style is same with CSS.
    map.setCursor('url(cursor.png) 4 12, auto');
    Parameter Type Description
    cursor String cursor style
    Returns:
    Map: this
  • resetCursor() [source]

  • Reset map's cursor style.
    map.resetCursor();
    Returns:
    Map: this
  • getCenter() [source]

  • Get center of the map.
    Returns:
    Coordinate:
  • setCenter(center) [source]

  • Set a new center to the map.
    Parameter Type Description
    center Coordinate
    Returns:
    Map: this
  • getSize() [source]

  • Get map's size (width and height) in pixel.
    Returns:
    Size:
  • getContainerExtent() [source]

  • Get container extent of the map
    Returns:
    PointExtent:
  • getExtent() [source]

  • Get the geographical extent of map's current view extent.
    Returns:
    Extent:
  • getProjExtent() [source]

  • Get the projected geographical extent of map's current view extent.
    Returns:
    Extent:
  • getPrjExtent() [source]

  • Alias for getProjExtent
    Returns:
    Extent:
  • getMaxExtent() [source]

  • Get the max extent that the map is restricted to.
    Returns:
    Extent:
  • setMaxExtent(extent) [source]

  • Sets the max extent that the map is restricted to.
    map.setMaxExtent(map.getExtent());
    Parameter Type Description
    extent Extent
    Returns:
    Map: this
  • getZoom() [source]

  • Get map's current zoom.
    Returns:
    Number:
  • getZoomForScale(scale, fromZoom, isFraction) [source]

  • Caculate the target zoom if scaling from "fromZoom" by "scale"
    Parameter Type Description
    scale Number
    fromZoom Number
    isFraction Boolean can return fractional zoom
    Returns:
    Number: zoom fit for scale starting from fromZoom
  • setZoom(zoom, optionsopt) [source]

  • Sets zoom of the map
    Parameter Type Default Description
    zoom Number
    options opt Object null options
    Properties
    Parameter Type Default Description
    animation opt Boolean true whether zoom is animation, true by default
    Returns:
    Map: this
  • getMaxZoom() [source]

  • Get the max zoom that the map can be zoom to.
    Returns:
    Number:
  • setMaxZoom(maxZoom) [source]

  • Sets the max zoom that the map can be zoom to.
    Parameter Type Description
    maxZoom Number
    Returns:
    Map: this
  • getMinZoom() [source]

  • Get the min zoom that the map can be zoom to.
    Returns:
    Number:
  • setMinZoom(minZoom) [source]

  • Sets the min zoom that the map can be zoom to.
    Parameter Type Description
    minZoom Number
    Returns:
    Map: this
  • getMaxNativeZoom() [source]

  • Maximum zoom the map has
    Returns:
    Number:
  • getGLZoom() [source]

  • Zoom for world point in WebGL context
    Returns:
    Number:
  • getGLScale(zoomopt) [source]

  • Caculate scale from gl zoom to given zoom (default by current zoom)
    Parameter Type Description
    zoom opt Number target zoom, current zoom by default
    Returns:
    Number:
  • zoomIn() [source]

  • zoom in
    Returns:
    Map: this
  • zoomOut() [source]

  • zoom out
    Returns:
    Map: this
  • isZooming() [source]

  • Whether the map is zooming
    Returns:
    Boolean:
  • isInteracting() [source]

  • Whether the map is being interacted
    Returns:
    Boolean:
  • setCenterAndZoom(center, zoom) [source]

  • Sets the center and zoom at the same time.
    Parameter Type Description
    center Coordinate
    zoom Number
    Returns:
    Map: this
  • getFitZoom(extent) [source]

  • Caculate the zoom level that contains the given extent with the maximum zoom level possible.
    Parameter Type Description
    extent Extent
    Returns:
    Number: zoom fit for the extent
  • getView() [source]

  • Get map's current view (center/zoom/pitch/bearing)
    Returns:
    Object: { center : *, zoom : *, pitch : *, bearing : * }
  • setView(view) [source]

  • Set map's center/zoom/pitch/bearing at one time
    Parameter Type Description
    view Object a object containing center/zoom/pitch/bearing return {Map} this

  • getResolution(zoom) [source]

  • Get map's resolution
    Parameter Type Description
    zoom Number zoom or current zoom if not given
    Returns:
    Number: resolution
  • getScale(zoom) [source]

  • Get scale of resolutions from zoom to max zoom
    Parameter Type Description
    zoom Number zoom or current zoom if not given
    Returns:
    Number: scale
  • fitExtent(extent, zoomOffset) [source]

  • Set the map to be fit for the given extent with the max zoom level possible.
    Parameter Type Description
    extent Extent extent
    zoomOffset Number zoom offset
    Returns:
    Map: - this
  • getBaseLayer() [source]

  • Get the base layer of the map.
    Returns:
    Layer:
  • setBaseLayer(baseLayer) [source]

  • Sets a new base layer to the map.
    Some events will be thrown such as baselayerchangestart, baselayerload, baselayerchangeend.
    Parameter Type Description
    baseLayer Layer new base layer
    Fires:
    Returns:
    Map: this
  • removeBaseLayer() [source]

  • Remove the base layer from the map
    Fires:
    Returns:
    Map: this
  • getLayers(filteropt) [source]

  • Get the layers of the map, except base layer (which should be by getBaseLayer).
    A filter function can be given to filter layers, e.g. exclude all the VectorLayers.
    var vectorLayers = map.getLayers(function (layer) {
        return (layer instanceof VectorLayer);
    });
    Parameter Type Description
    filter opt function a filter function of layers, return false to exclude the given layer.
    Returns:
    Array.<Layer>:
  • getLayer(id) [source]

  • Get the layer with the given id.
    Parameter Type Description
    id String layer id
    Returns:
    Layer:
  • addLayer(layer) [source]

  • Add a new layer on the top of the map.
    Parameter Type Description
    layer Layer | Array.<Layer> one or more layers to add
    Fires:
    Returns:
    Map: this
  • removeLayer(layer) [source]

  • Remove a layer from the map
    Parameter Type Description
    layer String | Array.<String> | Layer | Array.<Layer> one or more layers or layer ids
    Fires:
    Returns:
    Map: this
  • sortLayers(layers) [source]

  • Sort layers according to the order provided, the last will be on the top.
    map.addLayer([layer1, layer2, layer3]);
    map.sortLayers([layer2, layer3, layer1]);
    map.sortLayers(['3', '2', '1']); // sort by layer ids.
    Parameter Type Description
    layers Array.<string> | Array.<Layer> layers or layer ids to sort
    Returns:
    Map: this
  • toDataURL(optionsopt) [source]

  • Exports image from the map's canvas.
    Parameter Type Description
    options opt Object options
    Properties
    Parameter Type Default Description
    mimeType opt String image/png mime type of the image
    save opt Boolean false whether pop a file save dialog to save the export image.
    fileName opt String export specify the file name, if options.save is true.
    Returns:
    String: image of base64 format.
  • coordinateToPoint(coordinate, zoomopt) [source]

  • Converts a coordinate to the 2D point in current zoom or in the specific zoom.
    The 2D point's coordinate system's origin is the same with map's origin. Usually used in plugin development.
    var point = map.coordinateToPoint(new Coordinate(121.3, 29.1));
    Parameter Type Description
    coordinate Coordinate coordinate
    zoom opt Number zoom level
    Returns:
    Point: 2D point
  • coordToPoint() [source]

  • shorter alias for coordinateToPoint

  • pointToCoordinate(point, zoom) [source]

  • Converts a 2D point in current zoom or a specific zoom to a coordinate. Usually used in plugin development.
    var coord = map.pointToCoordinate(new Point(4E6, 3E4));
    Parameter Type Description
    point Point 2D point
    zoom Number point's zoom level
    Returns:
    Coordinate: coordinate
  • pointToCoord() [source]

  • shorter alias for pointToCoordinate

  • coordinateToViewPoint(coordinate) [source]

  • Converts a geographical coordinate to view point.
    A view point is a point relative to map's mapPlatform panel's position.
    Usually used in plugin development.
    Parameter Type Description
    coordinate Coordinate
    Returns:
    Point:
  • coordToViewPoint() [source]

  • shorter alias for coordinateToViewPoint

  • viewPointToCoordinate(viewPoint) [source]

  • Converts a view point to the geographical coordinate. Usually used in plugin development.
    Parameter Type Description
    viewPoint Point
    Returns:
    Coordinate:
  • viewPointToCoord() [source]

  • shorter alias for viewPointToCoordinate

  • coordinateToContainerPoint(coordinate, zoomopt) [source]

  • Convert a geographical coordinate to the container point.
    A container point is a point relative to map container's top-left corner.
    Parameter Type Description
    coordinate Coordinate coordinate
    zoom opt Number zoom level
    Returns:
    Point:
  • coordToContainerPoint() [source]

  • shorter alias for coordinateToContainerPoint

  • containerPointToCoordinate(containerPoint) [source]

  • Converts a container point to geographical coordinate.
    Parameter Type Description
    containerPoint Point
    Returns:
    Coordinate:
  • containerPointToCoord() [source]

  • shorter alias for containerPointToCoordinate

  • containerPointToViewPoint(containerPoint) [source]

  • Converts a container point to the view point. Usually used in plugin development.
    Parameter Type Description
    containerPoint Point
    Returns:
    Point:
  • viewPointToContainerPoint(viewPoint) [source]

  • Converts a view point to the container point. Usually used in plugin development.
    Parameter Type Description
    viewPoint Point
    Returns:
    Point:
  • containerToExtent(containerExtent) [source]

  • Converts a container point extent to the geographic extent.
    Parameter Type Description
    containerExtent PointExtent containeproints extent
    Returns:
    Extent: geographic extent
  • checkSize() [source]

  • Checks if the map container size changed and updates the map if so.
    Fires:
    Returns:
    Map: this
  • distanceToPixel(xDist, yDist) [source]

  • Converts geographical distances to the pixel length.
    The value varis with difference zoom level.
    Parameter Type Description
    xDist Number distance on X axis.
    yDist Number distance on Y axis.
    Returns:
    Size: result.width: pixel length on X axis; result.height: pixel length on Y axis
  • distanceToPoint(xDist, yDist, zoom) [source]

  • Converts geographical distances to the 2d point length.
    The value varis with difference zoom level.
    Parameter Type Description
    xDist Number distance on X axis.
    yDist Number distance on Y axis.
    zoom Number point's zoom
    Returns:
    Point:
  • pixelToDistance(width, height) [source]

  • Converts pixel size to geographical distance.
    Parameter Type Description
    width Number pixel width
    height Number pixel height
    Returns:
    Number: distance - Geographical distance
  • pointToDistance(dx, dy, zoom) [source]

  • Converts 2d point distances to geographic length.
    Parameter Type Description
    dx Number distance on X axis.
    dy Number distance on Y axis.
    zoom Number point's zoom
    Returns:
    Number: distance
  • locate(coordinate, dx, dy) [source]

  • Computes the coordinate from the given meter distance.
    Parameter Type Description
    coordinate Coordinate source coordinate
    dx Number meter distance on X axis
    dy Number meter distance on Y axis
    Returns:
    Coordinate: Result coordinate
  • locateByPoint(coordinate, px, py) [source]

  • Computes the coordinate from the given pixel distance.
    Parameter Type Description
    coordinate Coordinate source coordinate
    px Number pixel distance on X axis
    py Number pixel distance on Y axis
    Returns:
    Coordinate: Result coordinate
  • getMainPanel() [source]

  • Return map's main panel
    Returns:
    HTMLElement:
  • getPanels() [source]

  • Returns map panels.
    Returns:
    Object:
  • remove() [source]

  • Remove the map
    Returns:
    Map: this
  • isRemoved() [source]

  • whether the map is removed
    Returns:
    Boolean:
  • isMoving() [source]

  • Whether the map is moving
    Returns:
    Boolean:
  • (protected) _pointToExtent(extent2D) [source]

  • Converts a view point extent to the geographic extent.
    Parameter Type Description
    extent2D PointExtent view points extent
    Returns:
    Extent: geographic extent
  • offsetPlatform() [source]

  • Gets map panel's current view point.
    Returns:
    Point:
  • getViewPoint() [source]

  • Get map's view point, adding in frame offset
    Returns:
    Point: map view point
  • animateTo(view, optionsopt, stepopt) [source]

  • Update map's view with animation.
    map.animateTo({
        zoom : 13,
        center : [0, 0],
        pitch : 30,
        bearing : 60
    }, {
        duration : 6000,
        easing : 'out'
    }, function(frame) {
        if (frame.state.playState === 'finished') {
            console.log('animation finished');
        }
    });
    Parameter Type Default Description
    view Object view object
    options opt Object null
    Properties
    Parameter Type Default Description
    easing opt String out
    duration opt Number map.options.zoomAnimationDuration
    step opt function null step function during animation, animation frame as the parameter
    Returns:
    Map: this
  • isAnimating() [source]

  • Whether the map is animating with .animateTo
    Returns:
    Boolean:
  • getFov() [source]

  • Get map's fov (field of view);
    Returns:
    Number: fov in degree
  • setFov(fov) [source]

  • Set a new fov to map
    Parameter Type Description
    fov Number new fov in degree
    Returns:
    Map: this
  • getBearing() [source]

  • Get map's bearing
    Returns:
    Number: bearing in degree
  • setBearing(bearing) [source]

  • Set a new bearing to map
    Parameter Type Description
    bearing Number new bearing in degree
    Returns:
    Map: this
  • getPitch() [source]

  • Get map's pitch
    Returns:
    Number: pitch in degree
  • setPitch(pitch) [source]

  • Set a new pitch to map
    Parameter Type Description
    pitch Number new pitch in degree
    Returns:
    Map: this
  • isFullScreen() [source]

  • Returns:
    Boolean: Element is currently in fullscreen.
  • requestFullScreen() [source]

  • Request for the full screen
    Property Type Description
    dom Object containerDOM to requestFullScreen
    Properties:
    Name Type Description
    dom Object containerDOM to requestFullScreen
    Source:
    Fires:
    Returns:
    Map: this
  • cancelFullScreen() [source]

  • Cancel full screen
    Fires:
    Returns:
    Map: this
  • panTo(coordinate, optionsopt) [source]

  • Pan to the given coordinate
    Parameter Type Default Description
    coordinate Coordinate coordinate to pan to
    options opt Object null pan options
    Properties
    Parameter Type Default Description
    animation opt Boolean null whether pan with animation
    duration opt Boolean 600 pan animation duration
    Returns:
    Map: this
  • panBy(point, optionsopt) [source]

  • Pan the map by the give point
    Parameter Type Default Description
    point Point distance to pan, in pixel
    options opt Object null pan options
    Properties
    Parameter Type Default Description
    animation opt Boolean null whether pan with animation
    duration opt Boolean 600 pan animation duration
    Returns:
    Map: this
  • toJSON(optionsopt) [source]

  • Export the map's json, a snapshot of the map in JSON format.
    It can be used to reproduce the instance by fromJSON method
    Parameter Type Default Description
    options opt Object null export options
    Properties
    Parameter Type Default Description
    baseLayer opt Boolean | Object null whether to export base layer's JSON, if yes, it will be used as layer's toJSON options.
    clipExtent opt Boolean | Extent null if set with an extent instance, only the geometries intersectes with the extent will be exported. If set to true, map's current extent will be used.
    layers opt Boolean | Object | Array.<Object> null whether to export other layers' JSON, if yes, it will be used as layer's toJSON options. It can also be an array of layer export options with a "id" attribute to filter the layers to export.
    Returns:
    Object: layer's JSON
  • computeLength(coord1, coord2) [source]

  • Caculate distance of two coordinates.
    var distance = map.computeLength([0, 0], [0, 20]);
    Parameter Type Description
    coord1 Array.<Number> | Coordinate coordinate 1
    coord2 Array.<Number> | Coordinate coordinate 2
    Returns:
    Number: distance, unit is meter
  • computeGeometryLength(geometry) [source]

  • Caculate a geometry's length.
    Parameter Type Description
    geometry Geometry geometry to caculate
    Returns:
    Number: length, unit is meter
  • computeGeometryArea(geometry) [source]

  • Caculate a geometry's area.
    Parameter Type Description
    geometry Geometry geometry to caculate
    Returns:
    Number: area, unit is sq.meter
  • identify(opts, callback) [source]

  • Identify the geometries on the given coordinate.
    map.identify({
         coordinate: [0, 0],
         layers: [layer]
     },
     geos => {
         console.log(geos);
     });
    Parameter Type Description
    opts Object the identify options
    Properties
    Parameter Type Default Description
    coordinate Coordinate coordinate to identify
    layers Object the layers to perform identify on.
    filter opt function null filter function of the result geometries, return false to exclude.
    count opt Number null limit of the result count.
    tolerance opt Number 0 identify tolerance in pixel.
    includeInternals opt Boolean false whether to identify internal layers.
    includeInvisible opt Boolean false whether to identify invisible layers.
    callback function the callback function using the result geometries as the parameter.
    Returns:
    Map: this
  • zoomToPreviousView() [source]

  • Zoom to the previous map view in view history
    Returns:
    Object: map view
  • hasPreviousView() [source]

  • Whether has more previous view
    Returns:
    Boolean:
  • zoomToNextView() [source]

  • Zoom to the next view in view history
    Returns:
    Object: map view
  • hasNextView() [source]

  • Whether has more next view
    Returns:
    Boolean:
  • getViewHistory() [source]

  • Get map view history
    Returns:
    Array.<Object>:
  • addControl(control) [source]

  • Add a control on the map.
    Parameter Type Description
    control control.Control contorl to add
    Returns:
    Map: this
  • removeControl(control) [source]

  • Remove a control from the map.
    Parameter Type Description
    control control.Control control to remove
    Returns:
    Map: this
  • (mixin) on(eventsOn, handler, contextopt) [source]

  • Register a handler function to be called whenever this event is fired.
    foo.on('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventsOn String event types to register, seperated by space if more than one.
    handler function handler function to be called
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    Any: this
  • (mixin) addEventListener(eventTypes, handler, contextopt) [source]

  • Alias for on
    Parameter Type Default Description
    eventTypes String event types to register, seperated by space if more than one.
    handler function handler function to be called
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) once(eventTypes, handler, contextopt) [source]

  • Same as on, except the listener will only get fired once and then removed.
    foo.once('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventTypes String event types to register, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) off(eventsOff, handler, contextopt) [source]

  • Unregister the event handler for the specified event types.
    foo.off('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventsOff String event types to unregister, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) removeEventListener(eventTypes, handler, contextopt) [source]

  • Alias for off
    Parameter Type Default Description
    eventTypes String event types to unregister, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) listens(eventType, hanlderopt, contextopt) [source]

  • Returns listener's count registered for the event type.
    Parameter Type Default Description
    eventType String an event type
    hanlder opt function null listener function
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    Number:
  • (mixin) copyEventListeners(target) [source]

  • Copy all the event listener to the target object
    Parameter Type Description
    target Object target object to copy to.
    Mixes From:
    Returns:
    : this
  • (mixin) fire(eventType, param) [source]

  • Fire an event, causing all handlers for that event name to run.
    Parameter Type Description
    eventType String an event type to fire
    param Object parameters for the listener function.
    Mixes From:
    Returns:
    : this
  • (mixin) setMenu(options) [source]

  • Set a context menu
    foo.setMenu({
     'width'  : 160,
     'custom' : false,
     'items' : [
         //return false to prevent event propagation
        {'item': 'Query', 'click': function() {alert('Query Clicked!'); return false;}},
        '-',
        {'item': 'Edit', 'click': function() {alert('Edit Clicked!')}},
        {'item': 'About', 'click': function() {alert('About Clicked!')}}
       ]
    });
    Parameter Type Description
    options Object menu options
    Mixes From:
    Returns:
    *: this
  • (mixin) openMenu(coordinateopt) [source]

  • Open the context menu, default on the center of the geometry or map.
    Parameter Type Default Description
    coordinate opt Coordinate null coordinate to open the context menu
    Mixes From:
    Returns:
    *: this
  • (mixin) setMenuItems(items) [source]

  • Set menu items to the context menu
    Parameter Type Description
    items Array.<Object> menu items
    Mixes From:
    Returns:
    *: this
  • (mixin) getMenuItems() [source]

  • Get the context menu items
    Mixes From:
    Returns:
    Array.<Object>:
  • (mixin) closeMenu() [source]

  • Close the contexnt menu
    Mixes From:
    Returns:
    *: this
  • (mixin) removeMenu() [source]

  • Remove the context menu
    Mixes From:
    Returns:
    *: this
  • (mixin) registerRenderer(name, clazz) [source]

  • Register a renderer class with the given name.
    Parameter Type Description
    name String renderer's register key
    clazz function renderer's class, a function (not necessarily a Class).
    Mixes From:
    Returns:
    *: this
  • (mixin) getRendererClass(name) [source]

  • Get the registered renderer class by the given name
    Parameter Type Description
    name String renderer's register key
    Mixes From:
    Returns:
    function: renderer's class
  • (inherited) callInitHooks() [source]

  • Visit and call all the init hooks defined on Class and its parents.
    Inherited From:
    Returns:
    Class: this
  • (inherited) setOptions(options) [source]

  • Merges options with the default options of the object.
    Parameter Type Description
    options Object options to set
    Inherited From:
    Returns:
    Class: this
  • (inherited) config(conf) [source]

  • 1. Return object's options if no parameter is provided.
    2. update an option and enable/disable the handler if a handler with the same name existed.
    // Get marker's options;
    var options = marker.config();
    // Set map's option "draggable" to false and disable map's draggable handler.
    map.config('draggable', false);
    // You can update more than one options like this:
    map.config({
        'scrollWheelZoom' : false,
        'doubleClickZoom' : false
    });
    Parameter Type Description
    conf Object config to update
    Inherited From:
    Returns:
    Class: this

    Events

  • spatialreferencechange [source]

  • spatialreferencechange event, fired when map's spatial reference is updated.
    Properties:
    Name Type Description
    type String spatialreferencechange
    target Map map
    old Map the old spatial reference
    new Map the new spatial reference changed to
    Source:

  • baselayerchangestart [source]

  • baselayerchangestart event, fired when base layer is changed.
    Properties:
    Name Type Description
    type String baselayerchangestart
    target Map map
    Source:

  • baselayerchangeend [source]

  • baselayerchangeend event, fired when base layer is changed.
    Properties:
    Name Type Description
    type String baselayerchangeend
    target Map map
    Source:

  • setbaselayer [source]

  • setbaselayer event, fired when base layer is set.
    Properties:
    Name Type Description
    type String setbaselayer
    target Map map
    Source:

  • baselayerload [source]

  • baselayerload event, fired when base layer is loaded.
    Properties:
    Name Type Description
    type String baselayerload
    target Map map
    Source:

  • baselayerremove [source]

  • baselayerremove event, fired when base layer is removed.
    Properties:
    Name Type Description
    type String baselayerremove
    target Map map
    Source:

  • addlayer [source]

  • addlayer event, fired when adding layers.
    Properties:
    Name Type Description
    type String addlayer
    target Map map
    layers Array.<Layer> layers to add
    Source:

  • removelayer [source]

  • removelayer event, fired when removing layers.
    Properties:
    Name Type Description
    type String removelayer
    target Map map
    layers Array.<Layer> layers to remove
    Source:

  • resize [source]

  • resize event when map container's size changes
    Properties:
    Name Type Description
    type String resize
    target Map map fires the event
    Source:

  • movestart [source]

  • movestart event
    Properties:
    Name Type Description
    type String movestart
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • moving [source]

  • moving event
    Properties:
    Name Type Description
    type String moving
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • moveend [source]

  • moveend event
    Properties:
    Name Type Description
    type String moveend
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • dragrotatestart [source]

  • dragrotatestart event
    Properties:
    Name Type Description
    type String dragrotatestart
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • dragrotating [source]

  • dragrotating event
    Properties:
    Name Type Description
    type String dragrotating
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • dragrotateend [source]

  • dragrotateend event
    Properties:
    Name Type Description
    type String dragrotateend
    target Map map fires the event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • animating [source]

  • fired when map is animating. (panning, zooming, rotating)
    Properties:
    Name Type Description
    type String animating
    target Map the map fires the event
    Source:

  • animateinterrupted [source]

  • fired when map's animation is interrupted by mouse event or else.
    Properties:
    Name Type Description
    type String animateinterrupted
    target Map the map fires the event
    Source:

  • animateend [source]

  • fired when map's animation ended (panning, zooming, rotating).
    Properties:
    Name Type Description
    type String animateend
    target Map the map fires the event
    Source:

  • animatestart [source]

  • fired when map starts to animate (panning, zooming, rotating).
    Properties:
    Name Type Description
    type String animatestart
    target Map the map fires the event
    Source:

  • pitch [source]

  • pitch event, alias of pitchend, deprecated
    Properties:
    Name Type Description
    type String pitch
    target Map the map fires event
    from Number pitch from
    to Number pitch to
    Source:

  • pitchend [source]

  • pitchend event
    Properties:
    Name Type Description
    type String pitchend
    target Map the map fires event
    from Number pitchend from
    to Number pitchend to
    Source:

  • mousedown [source]

  • mousedown event
    Properties:
    Name Type Description
    type String mousedown
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mouseup [source]

  • mouseup event
    Properties:
    Name Type Description
    type String mouseup
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mouseover [source]

  • mouseover event
    Properties:
    Name Type Description
    type String mouseover
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mouseout [source]

  • mouseout event
    Properties:
    Name Type Description
    type String mouseout
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mouseenter [source]

  • mouseenter event
    Properties:
    Name Type Description
    type String mouseenter
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mouseleave [source]

  • mouseleave event
    Properties:
    Name Type Description
    type String mouseleave
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • mousemove [source]

  • mousemove event
    Properties:
    Name Type Description
    type String mousemove
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • click [source]

  • click event
    Properties:
    Name Type Description
    type String click
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • dblclick [source]

  • dblclick event
    Properties:
    Name Type Description
    type String dblclick
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • contextmenu [source]

  • contextmenu event
    Properties:
    Name Type Description
    type String contextmenu
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • keypress [source]

  • keypress event
    Properties:
    Name Type Description
    type String keypress
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • touchstart [source]

  • touchstart event
    Properties:
    Name Type Description
    type String touchstart
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • touchmove [source]

  • touchmove event
    Properties:
    Name Type Description
    type String touchmove
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • touchend [source]

  • touchend event
    Properties:
    Name Type Description
    type String touchend
    target Map the map fires event
    coordinate Coordinate coordinate of the event
    containerPoint Point container point of the event
    viewPoint Point view point of the event
    domEvent Event dom event
    Source:

  • fullscreenstart [source]

  • fullscreenstart event
    Properties:
    Name Type Description
    type String fullscreenstart
    target Map the map fires event
    Source:

  • fullscreenend [source]

  • fullscreenend event
    Properties:
    Name Type Description
    type String fullscreenend
    target Map the map fires event
    Source:

  • cancelfullscreen [source]

  • cancelfullscreen event
    Properties:
    Name Type Description
    type String cancelfullscreen
    target Map the map fires event
    Source:

  • viewchange [source]

  • viewchange event
    Properties:
    Name Type Description
    type String viewchange
    target Map map fires the event
    old Object old view
    new Point new view
    Source:

  • zoomstart [source]

  • zoomstart event
    Properties:
    Name Type Description
    type String zoomstart
    target Map the map fires event
    from Number zoom level zooming from
    to Number zoom level zooming to
    Source:

  • zooming [source]

  • zooming event
    Properties:
    Name Type Description
    type String zooming
    target Map the map fires event
    from Number zoom level zooming from
    to Number zoom level zooming to
    Source:

  • zoomend [source]

  • zoomend event
    Properties:
    Name Type Description
    type String zoomend
    target Map the map fires event
    from Number zoom level zooming from
    to Number zoom level zooming to
    Source:

  • touchactstart [source]

  • touchactstart event
    Properties:
    Name Type Description
    type String touchactstart
    target Map the map fires event
    Source:

  • touchacting [source]

  • touchacting event
    Properties:
    Name Type Description
    type String touchacting
    target Map the map fires event
    Source:

  • touchactend [source]

  • touchactend event
    Properties:
    Name Type Description
    type String touchactend
    target Map the map fires event
    Source: