From ca0f0eb947deb01a776b56107a42dad33e68b85b Mon Sep 17 00:00:00 2001 From: liubgithub <471071362@qq.com> Date: Mon, 11 Mar 2024 11:48:33 +0800 Subject: [PATCH] map's center support altitude --- docs/api/0.x/renderer.CanvasRenderer.html | 9154 +++++++++-------- docs/api/1.x/renderer.CanvasRenderer.html | 9114 ++++++++-------- src/core/util/vec3.js | 13 + src/map/Map.Camera.js | 71 +- src/map/Map.js | 4 + src/renderer/geometry/Painter.js | 2 +- src/renderer/layer/CanvasRenderer.js | 22 +- .../vectorlayer/VectorLayerCanvasRenderer.js | 2 +- test/layer/CanvasLayerSpec.js | 2 +- test/map/MapCameraSpec.js | 26 +- test/map/MapSpec.js | 9 + test/map/MapViewHistorySpec.js | 2 +- test/map/control/Control.OverviewSpec.js | 2 +- test/map/control/Control.ResetSpec.js | 8 +- 14 files changed, 9264 insertions(+), 9167 deletions(-) diff --git a/docs/api/0.x/renderer.CanvasRenderer.html b/docs/api/0.x/renderer.CanvasRenderer.html index c7257d579..0f1f78e6a 100644 --- a/docs/api/0.x/renderer.CanvasRenderer.html +++ b/docs/api/0.x/renderer.CanvasRenderer.html @@ -1,4568 +1,4586 @@ - - - - - - Class: CanvasRenderer - - - - - - - - - - - -

Class: CanvasRenderer

-
- - - - - - - - - -
- - - -
- -

- renderer.CanvasRenderer

- -
Base Class to render layer on HTMLCanvasElement
- - -
- -
-
- - - - - -

(abstract, protected) new renderer.CanvasRenderer(layer) - - - [source] - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterTypeDescription
layer - - - - -Layer - - - - the layer to render
- - - - - - - - -
Extends:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - -

Methods

- - - - - -
  • - -

    render() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Render the layer. Call checkResources -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (abstract) checkResources() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Check if has any external resources to load If yes, load the resources before calling draw method -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Array.<Array>: - - - - an array of resource arrays [ [url1, width, height], [url2, width, height], [url3, width, height] .. ] - - - - - - - -
    - - - - - -
  • - -

    (abstract) draw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - a required abstract method to implement draw the layer when map is not interacting -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (abstract) drawOnInteracting(eventParam) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - an optional abstract method to implement draw the layer when map is interacting (moving/zooming/dragrotating) -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    eventParam - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    needToRedraw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Ask whether the layer renderer needs to redraw -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    onSkipDrawOnInteracting() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - A callback for overriding when drawOnInteracting is skipped due to low fps -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    mustRenderOnInteracting() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Whether must call render instead of drawOnInteracting when map is interacting -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setToRedraw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Set to redraw, ask map to call draw/drawOnInteracting to redraw the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setCanvasUpdated() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Mark layer's canvas updated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (protected) isCanvasUpdated() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Only called by map's renderer to check whether the layer's canvas is updated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    remove() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Remove the renderer, will be called when layer is removed -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getMap() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get map -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Map: - - - - - - - -
    - - - - - -
  • - -

    getCanvasImage() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's Canvas image object -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -HTMLCanvasElement: - - - - - - - -
    - - - - - -
  • - -

    clear() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Clear canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    isBlank() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - A method to help improve performance. If you are sure that layer's canvas is blank, returns true to save unnecessary layer works of maps. -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    show() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Show the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    hide() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Hide the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setZIndex() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Set z-index of layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    hitDetect(point) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Detect if there is anything painted on the given point -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    point - - - - -Point - - - - containerPoint
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    loadResources(resourceUrls, onComplete, context) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - loadResource from resourceUrls -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    resourceUrls - - - - -Array.<String> - - - - Array of urls to load
    onComplete - - - - -function - - - - callback after loading complete
    context - - - - -Object - - - - callback's context
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Array.<Promise>: - - - - - - - -
    - - - - - -
  • - -

    createCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Create renderer's Canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    resizeCanvas(canvasSize) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Resize the canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    canvasSize - - - - -Size - - - - the size resizing to
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    clearCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Clear the canvas to blank -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    prepareCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Prepare the canvas for rendering.
    1. Clear the canvas to blank.
    2. Clip the canvas by mask if there is any and return the mask's extent -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -PointExtent: - - - - mask's extent of current zoom's 2d point. - - - - - - - -
    - - - - - -
  • - -

    getViewExtent() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's current view extent in 2d point -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Object: - - - - view.extent, view.maskExtent, view.zoom, view.southWest - - - - - - - -
    - - - - - -
  • - -

    completeRender() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - call when rendering completes, this will fire necessary events and call setCanvasUpdated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getEvents() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's event map registered on the map -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Object: - - - - events - - - - - - - -
    - - - - - -
  • - -

    onZoomStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - /** onZoomStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onZoomEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onZoomEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onZooming(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onZooming -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoveStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoveStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoving(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoving -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoveEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoveEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onResize(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onResize -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotateStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotateStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotating(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotating -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotateEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotateEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onSpatialReferenceChange(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onSpatialReferenceChange -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getDrawTime() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get ellapsed time of previous drawing -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Number: - - - - - - - -
    - - - - - -
  • - -

    (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. -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    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
    });
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    conf - - - - -Object - - - - config to update
    - - - - - - - - - - - - - -
    Inherited From:
    - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Class: - - - - this - - - - - - - -
    - - - - - -
  • - -

    (inherited) onConfig() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Default callback when config is called -
    - - - - - - - - - - - - - - - - - - - - -
    Inherited From:
    - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - -
    - -
    - - - - -
    - - - -
    - - - - - - - - \ No newline at end of file + + + + + + Class: CanvasRenderer + + + + + + + + + + + +

    Class: CanvasRenderer

    +
    + + + + + + + + + +
    + + + +
    + +

    + renderer.CanvasRenderer

    + +
    Base Class to render layer on HTMLCanvasElement
    + + +
    + +
    +
    + + + + + +

    (abstract, protected) new renderer.CanvasRenderer(layer) + + + [source] + + + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    layer + + + + +Layer + + + + the layer to render
    + + + + + + + + +
    Extends:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + +

    Methods

    + + + + + +
  • + +

    render() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Render the layer. +Call checkResources +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (abstract) checkResources() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Check if has any external resources to load +If yes, load the resources before calling draw method +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Array.<Array>: + + + + an array of resource arrays [ [url1, width, height], [url2, width, height], [url3, width, height] .. ] + + + + + + + +
    + + + + + +
  • + +

    (abstract) draw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + a required abstract method to implement +draw the layer when map is not interacting +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (abstract) drawOnInteracting(eventParam) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + an optional abstract method to implement +draw the layer when map is interacting (moving/zooming/dragrotating) +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    eventParam + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    needToRedraw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Ask whether the layer renderer needs to redraw +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    onSkipDrawOnInteracting() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + A callback for overriding when drawOnInteracting is skipped due to low fps +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    mustRenderOnInteracting() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Whether must call render instead of drawOnInteracting when map is interacting +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setToRedraw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Set to redraw, ask map to call draw/drawOnInteracting to redraw the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setCanvasUpdated() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Mark layer's canvas updated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (protected) isCanvasUpdated() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Only called by map's renderer to check whether the layer's canvas is updated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    remove() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Remove the renderer, will be called when layer is removed +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getMap() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get map +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Map: + + + + + + + +
    + + + + + +
  • + +

    getCanvasImage() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's Canvas image object +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +HTMLCanvasElement: + + + + + + + +
    + + + + + +
  • + +

    clear() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Clear canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    isBlank() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + A method to help improve performance. +If you are sure that layer's canvas is blank, returns true to save unnecessary layer works of maps. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    show() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Show the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    hide() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Hide the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setZIndex() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Set z-index of layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    hitDetect(point) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Detect if there is anything painted on the given point +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    point + + + + +Point + + + + containerPoint
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    loadResources(resourceUrls, onComplete, context) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + loadResource from resourceUrls +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    resourceUrls + + + + +Array.<String> + + + + Array of urls to load
    onComplete + + + + +function + + + + callback after loading complete
    context + + + + +Object + + + + callback's context
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Array.<Promise>: + + + + + + + +
    + + + + + +
  • + +

    createCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Create renderer's Canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    resizeCanvas(canvasSize) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Resize the canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    canvasSize + + + + +Size + + + + the size resizing to
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    clearCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Clear the canvas to blank +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    prepareCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Prepare the canvas for rendering.
    +1. Clear the canvas to blank.
    +2. Clip the canvas by mask if there is any and return the mask's extent +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +PointExtent: + + + + mask's extent of current zoom's 2d point. + + + + + + + +
    + + + + + +
  • + +

    getViewExtent() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's current view extent in 2d point +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Object: + + + + view.extent, view.maskExtent, view.zoom, view.middleWest + + + + + + + +
    + + + + + +
  • + +

    completeRender() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + call when rendering completes, this will fire necessary events and call setCanvasUpdated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getEvents() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's event map registered on the map +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Object: + + + + events + + + + + + + +
    + + + + + +
  • + +

    onZoomStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + /** +onZoomStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onZoomEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onZoomEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onZooming(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onZooming +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoveStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoveStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoving(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoving +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoveEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoveEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onResize(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onResize +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotateStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotateStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotating(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotating +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotateEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotateEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onSpatialReferenceChange(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onSpatialReferenceChange +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getDrawTime() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get ellapsed time of previous drawing +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Number: + + + + + + + +
    + + + + + +
  • + +

    (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. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    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
    +});
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    conf + + + + +Object + + + + config to update
    + + + + + + + + + + + + + +
    Inherited From:
    + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Class: + + + + this + + + + + + + +
    + + + + + +
  • + +

    (inherited) onConfig() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Default callback when config is called +
    + + + + + + + + + + + + + + + + + + + + +
    Inherited From:
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + +
    + +
    + + + + +
    + + + +
    + + + + + + + + diff --git a/docs/api/1.x/renderer.CanvasRenderer.html b/docs/api/1.x/renderer.CanvasRenderer.html index baf9b18d3..0be00f370 100644 --- a/docs/api/1.x/renderer.CanvasRenderer.html +++ b/docs/api/1.x/renderer.CanvasRenderer.html @@ -1,4548 +1,4566 @@ - - - - - - Class: CanvasRenderer - - - - - - - - - - - -

    Class: CanvasRenderer

    -
    - - - - - - - - - -
    - - - -
    - -

    - renderer.CanvasRenderer

    - -
    Base Class to render layer on HTMLCanvasElement
    - - -
    - -
    -
    - - - - - -

    (abstract, protected) new renderer.CanvasRenderer(layer) - - - [source] - - - - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    layer - - - - -Layer - - - - the layer to render
    - - - - - - - - -
    Extends:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - - - - - - - - - - - - - - - - - -

    Methods

    - - - - - -
  • - -

    render() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Render the layer. Call checkResources -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (abstract) checkResources() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Check if has any external resources to load If yes, load the resources before calling draw method -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Array.<Array>: - - - - an array of resource arrays [ [url1, width, height], [url2, width, height], [url3, width, height] .. ] - - - - - - - -
    - - - - - -
  • - -

    (abstract) draw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - a required abstract method to implement draw the layer when map is not interacting -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (abstract) drawOnInteracting(eventParam) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - an optional abstract method to implement draw the layer when map is interacting (moving/zooming/dragrotating) -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    eventParam - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    needToRedraw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Ask whether the layer renderer needs to redraw -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    onSkipDrawOnInteracting() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - A callback for overriding when drawOnInteracting is skipped due to low fps -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    mustRenderOnInteracting() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Whether must call render instead of drawOnInteracting when map is interacting -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setToRedraw() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Set to redraw, ask map to call draw/drawOnInteracting to redraw the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setCanvasUpdated() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Mark layer's canvas updated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    (protected) isCanvasUpdated() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Only called by map's renderer to check whether the layer's canvas is updated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    remove() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Remove the renderer, will be called when layer is removed -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getMap() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get map -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Map: - - - - - - - -
    - - - - - -
  • - -

    getCanvasImage() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's Canvas image object -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -HTMLCanvasElement: - - - - - - - -
    - - - - - -
  • - -

    clear() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Clear canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    isBlank() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - A method to help improve performance. If you are sure that layer's canvas is blank, returns true to save unnecessary layer works of maps. -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    show() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Show the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    hide() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Hide the layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    setZIndex() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Set z-index of layer -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    hitDetect(point) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Detect if there is anything painted on the given point -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    point - - - - -Point - - - - containerPoint
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Boolean: - - - - - - - -
    - - - - - -
  • - -

    loadResources(resourceUrls, onComplete, context) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - loadResource from resourceUrls -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    resourceUrls - - - - -Array.<String> - - - - Array of urls to load
    onComplete - - - - -function - - - - callback after loading complete
    context - - - - -Object - - - - callback's context
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Array.<Promise>: - - - - - - - -
    - - - - - -
  • - -

    createCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Create renderer's Canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    resizeCanvas(canvasSize) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Resize the canvas -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    canvasSize - - - - -Size - - - - the size resizing to
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    clearCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Clear the canvas to blank -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    prepareCanvas() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Prepare the canvas for rendering.
    1. Clear the canvas to blank.
    2. Clip the canvas by mask if there is any and return the mask's extent -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -PointExtent: - - - - mask's extent of current zoom's 2d point. - - - - - - - -
    - - - - - -
  • - -

    getViewExtent() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's current view extent in 2d point -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Object: - - - - view.extent, view.maskExtent, view.zoom, view.southWest - - - - - - - -
    - - - - - -
  • - -

    completeRender() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - call when rendering completes, this will fire necessary events and call setCanvasUpdated -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getEvents() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get renderer's event map registered on the map -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Object: - - - - events - - - - - - - -
    - - - - - -
  • - -

    onZoomStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - /** onZoomStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onZoomEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onZoomEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onZooming(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onZooming -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoveStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoveStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoving(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoving -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onMoveEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onMoveEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onResize(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onResize -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotateStart(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotateStart -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotating(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotating -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onDragRotateEnd(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onDragRotateEnd -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    onSpatialReferenceChange(param) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - onSpatialReferenceChange -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    param - - - - -Object - - - - event parameters
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - -
  • - -

    getDrawTime() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Get ellapsed time of previous drawing -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Number: - - - - - - - -
    - - - - - -
  • - -

    (inherited) callInitHooks() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Visit and call all the init hooks defined on Class and its parents. -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Class: - - - - this - - - - - - - -
    - - - - - -
  • - -

    (inherited) setOptions(options) - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Merges options with the default options of the object. -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    options - - - - -Object - - - - options to set
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    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
    });
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParameterTypeDescription
    conf - - - - -Object - - - - config to update
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Returns:
    -Class: - - - - this - - - - - - - -
    - - - - - -
  • - -

    (inherited) onConfig() - - - [source] - - - - -

    - - -
  • - - - - - - -
    - Default callback when config is called -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - -
    - -
    - - - - -
    - - - -
    - - - - - - - - \ No newline at end of file + + + + + + Class: CanvasRenderer + + + + + + + + + + + +

    Class: CanvasRenderer

    +
    + + + + + + + + + +
    + + + +
    + +

    + renderer.CanvasRenderer

    + +
    Base Class to render layer on HTMLCanvasElement
    + + +
    + +
    +
    + + + + + +

    (abstract, protected) new renderer.CanvasRenderer(layer) + + + [source] + + + + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    layer + + + + +Layer + + + + the layer to render
    + + + + + + + + +
    Extends:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + + + + + + + + + + +

    Methods

    + + + + + +
  • + +

    render() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Render the layer. +Call checkResources +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (abstract) checkResources() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Check if has any external resources to load +If yes, load the resources before calling draw method +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Array.<Array>: + + + + an array of resource arrays [ [url1, width, height], [url2, width, height], [url3, width, height] .. ] + + + + + + + +
    + + + + + +
  • + +

    (abstract) draw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + a required abstract method to implement +draw the layer when map is not interacting +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (abstract) drawOnInteracting(eventParam) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + an optional abstract method to implement +draw the layer when map is interacting (moving/zooming/dragrotating) +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    eventParam + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    needToRedraw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Ask whether the layer renderer needs to redraw +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    onSkipDrawOnInteracting() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + A callback for overriding when drawOnInteracting is skipped due to low fps +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    mustRenderOnInteracting() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Whether must call render instead of drawOnInteracting when map is interacting +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setToRedraw() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Set to redraw, ask map to call draw/drawOnInteracting to redraw the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setCanvasUpdated() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Mark layer's canvas updated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    (protected) isCanvasUpdated() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Only called by map's renderer to check whether the layer's canvas is updated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    remove() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Remove the renderer, will be called when layer is removed +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getMap() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get map +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Map: + + + + + + + +
    + + + + + +
  • + +

    getCanvasImage() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's Canvas image object +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +HTMLCanvasElement: + + + + + + + +
    + + + + + +
  • + +

    clear() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Clear canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    isBlank() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + A method to help improve performance. +If you are sure that layer's canvas is blank, returns true to save unnecessary layer works of maps. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    show() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Show the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    hide() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Hide the layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    setZIndex() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Set z-index of layer +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    hitDetect(point) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Detect if there is anything painted on the given point +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    point + + + + +Point + + + + containerPoint
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Boolean: + + + + + + + +
    + + + + + +
  • + +

    loadResources(resourceUrls, onComplete, context) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + loadResource from resourceUrls +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    resourceUrls + + + + +Array.<String> + + + + Array of urls to load
    onComplete + + + + +function + + + + callback after loading complete
    context + + + + +Object + + + + callback's context
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Array.<Promise>: + + + + + + + +
    + + + + + +
  • + +

    createCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Create renderer's Canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    resizeCanvas(canvasSize) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Resize the canvas +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    canvasSize + + + + +Size + + + + the size resizing to
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    clearCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Clear the canvas to blank +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    prepareCanvas() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Prepare the canvas for rendering.
    +1. Clear the canvas to blank.
    +2. Clip the canvas by mask if there is any and return the mask's extent +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +PointExtent: + + + + mask's extent of current zoom's 2d point. + + + + + + + +
    + + + + + +
  • + +

    getViewExtent() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's current view extent in 2d point +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Object: + + + + view.extent, view.maskExtent, view.zoom, view.middleWest + + + + + + + +
    + + + + + +
  • + +

    completeRender() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + call when rendering completes, this will fire necessary events and call setCanvasUpdated +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getEvents() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get renderer's event map registered on the map +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Object: + + + + events + + + + + + + +
    + + + + + +
  • + +

    onZoomStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + /** +onZoomStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onZoomEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onZoomEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onZooming(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onZooming +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoveStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoveStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoving(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoving +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onMoveEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onMoveEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onResize(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onResize +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotateStart(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotateStart +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotating(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotating +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onDragRotateEnd(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onDragRotateEnd +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    onSpatialReferenceChange(param) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + onSpatialReferenceChange +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    param + + + + +Object + + + + event parameters
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + +
  • + +

    getDrawTime() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Get ellapsed time of previous drawing +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Number: + + + + + + + +
    + + + + + +
  • + +

    (inherited) callInitHooks() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Visit and call all the init hooks defined on Class and its parents. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Class: + + + + this + + + + + + + +
    + + + + + +
  • + +

    (inherited) setOptions(options) + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Merges options with the default options of the object. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    options + + + + +Object + + + + options to set
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    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
    +});
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ParameterTypeDescription
    conf + + + + +Object + + + + config to update
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Returns:
    +Class: + + + + this + + + + + + + +
    + + + + + +
  • + +

    (inherited) onConfig() + + + [source] + + + + +

    + + +
  • + + + + + + +
    + Default callback when config is called +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + +
    + +
    + + + + +
    + + + +
    + + + + + + + + diff --git a/src/core/util/vec3.js b/src/core/util/vec3.js index 818e9ec47..c4844496d 100644 --- a/src/core/util/vec3.js +++ b/src/core/util/vec3.js @@ -162,3 +162,16 @@ function hypot() { while (i--) y += arguments[i] * arguments[i]; return Math.sqrt(y); } + +export function angle(a, b) { + normalize(a, a); + normalize(b, b); + const cosine = dot(a, b); + if (cosine > 1.0) { + return 0; + } else if (cosine < -1.0) { + return Math.PI; + } else { + return Math.acos(cosine); + } +} diff --git a/src/map/Map.Camera.js b/src/map/Map.Camera.js index 598ed232f..bc6b89420 100644 --- a/src/map/Map.Camera.js +++ b/src/map/Map.Camera.js @@ -2,7 +2,7 @@ import Map from './Map'; import Point from '../geo/Point'; import Coordinate from '../geo/Coordinate'; import * as mat4 from '../core/util/mat4'; -import { subtract, add, scale, normalize, dot, set, distance } from '../core/util/vec3'; +import { subtract, add, scale, normalize, dot, set, distance, angle } from '../core/util/vec3'; import { clamp, interpolate, isNumber, isNil, wrap, toDegree, toRadian } from '../core/util'; import { applyMatrix, matrixToQuaternion, quaternionToMatrix, lookAt, setPosition } from '../core/util/math'; import Browser from '../core/Browser'; @@ -11,6 +11,7 @@ const RADIAN = Math.PI / 180; const DEFAULT_FOV = 0.6435011087932844; const TEMP_COORD = new Coordinate(0, 0); const TEMP_POINT = new Point(0, 0); +const SOUTH = [0, -1, 0], BEARING = []; const altitudesHasData = (altitudes) => { if (isNumber(altitudes)) { @@ -287,26 +288,10 @@ Map.include(/** @lends Map.prototype */{ * @property {Number} pitch * @property {Number} bearing */ - setCameraPosition(params) { + setCameraOrientation(params) { const { position, pitch, bearing } = params; - - const cameraAltitude = position[2] * this._meterToGLPoint; - - const centerAltitude = this.centerAltitude || 0; - const centerPointZ = centerAltitude * this._meterToGLPoint; - - const cz = cameraAltitude - centerPointZ; - - const pitchRadian = pitch * RADIAN; - - const cameraToGroundDistance = cz / Math.cos(pitchRadian); - - const dist = Math.sin(pitchRadian) * cameraToGroundDistance; - - const cameraToCenterDistance = cameraToGroundDistance + centerPointZ; - - const zoom = this._getZoomFromCameraToCenterDistance(cameraToCenterDistance); - + const { zoom, cameraToGroundDistance } = this.getFitZoomForCamera(position, pitch); + const dist = Math.sin(pitch * RADIAN) * cameraToGroundDistance; const wrapBearing = wrap(bearing, -180, 180); const bearingRadian = wrapBearing * RADIAN; @@ -329,7 +314,43 @@ Map.include(/** @lends Map.prototype */{ return this; }, - _getZoomFromCameraToCenterDistance(distance) { + //设置相机的坐标, 根据地图中心点和相机位置,反算地图的bearing、pitch、zoom + setCameraPosition(coordinate) { + const glRes = this.getGLRes(); + const cameraPoint = this.coordToPointAtRes(coordinate, glRes); + cameraPoint.z = this.altitudeToPoint(coordinate.z || 0, glRes); + const center = this.getCenter(); + const centerPoint = this.coordToPointAtRes(center, glRes); + centerPoint.z = this.altitudeToPoint(center.z, glRes); + const direction = subtract([], cameraPoint.toArray(), centerPoint.toArray()); + set(this.cameraUp || [0, 0, 0], 0, 0, 1); + this._pitch = angle(direction, this.cameraUp); + set(BEARING, direction[0], direction[1], 0); + this._angle = -angle(BEARING, SOUTH); + this._zoomLevel = this.getFitZoomForCamera(coordinate, this._pitch).zoom; + this._calcMatrices(); + }, + + getFitZoomForCamera(cameraPosition, pitch) { + const z = Array.isArray(cameraPosition) ? cameraPosition[2] : cameraPosition.z; + const cameraAltitude = z * this._meterToGLPoint; + + const centerAltitude = this.centerAltitude || 0; + const centerPointZ = centerAltitude * this._meterToGLPoint; + + const cz = cameraAltitude - centerPointZ; + + const pitchRadian = pitch * RADIAN; + + const cameraToGroundDistance = cz / Math.cos(pitchRadian); + + const cameraToCenterDistance = cameraToGroundDistance + centerPointZ; + + const zoom = this._getFitZoomForDistance(cameraToCenterDistance); + return { zoom, cameraToGroundDistance }; + }, + + _getFitZoomForDistance(distance) { const ratio = this._getFovRatio(); const scale = distance * ratio * 2 / (this.height || 1) * this.getGLRes(); const resolutions = this._getResolutions(); @@ -712,7 +733,8 @@ Map.include(/** @lends Map.prototype */{ } const center2D = this._prjToPointAtRes(this._prjCenter, glRes, TEMP_POINT); - const centerAltitude = this.centerAltitude || 0; + const altitude = this.getCenter().z; + const centerAltitude = altitude !== undefined ? altitude : this.centerAltitude || 0; const centerPointZ = centerAltitude * this._meterToGLPoint; this.cameraLookAt = set(this.cameraLookAt || [0, 0, 0], center2D.x, center2D.y, centerPointZ); @@ -749,7 +771,8 @@ Map.include(/** @lends Map.prototype */{ // let up = new vec3(0,1,0); // up.rotateZ(target,radians); const d = dist || 1; - const up = this.cameraUp = set(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0); + // const up = this.cameraUp = set(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0); + const up = this.cameraUp = this.getPitch() > 0 ? set(this.cameraUp || [0, 0, 0], 0, 0, 1) : set(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0); const m = this.cameraWorldMatrix = this.cameraWorldMatrix || createMat4(); lookAt(m, this.cameraPosition, this.cameraLookAt, up); @@ -775,7 +798,7 @@ Map.include(/** @lends Map.prototype */{ }, _recenterOnTerrain() { - if (this.centerAltitude === undefined) { + if (this.centerAltitude === undefined || this._centerZ !== undefined) { return; } let queriedAltitude = this._queryTerrainByProjCoord(this._prjCenter); diff --git a/src/map/Map.js b/src/map/Map.js index f9ebd7875..a882c7595 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -235,6 +235,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) { this._zoomLevel = zoom; this._center = center; + this._centerZ = center.z; this.setSpatialReference(opts['spatialReference'] || opts['view']); @@ -488,6 +489,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) { const center = projection.unproject(this._prjCenter); center.x = Math.round(center.x * 1E8) / 1E8; center.y = Math.round(center.y * 1E8) / 1E8; + center.z = this._centerZ; if (this.centerAltitude) { center.z = this.centerAltitude; } @@ -521,6 +523,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) { this._center = center; return this; } + this._centerZ = center.z || 0; this.onMoveStart(); this._setPrjCenter(pcenter); this.onMoveEnd(this._parseEventFromCoord(this.getCenter())); @@ -2005,6 +2008,7 @@ class Map extends Handlerable(Eventable(Renderable(Class))) { delete this._glRes; const projection = this.getProjection(); this._prjCenter = projection.project(this._center); + this._prjCenter.z = this._center.z; this._calcMatrices(); const renderer = this._getRenderer(); if (renderer) { diff --git a/src/renderer/geometry/Painter.js b/src/renderer/geometry/Painter.js index e9db2575e..6aa488705 100644 --- a/src/renderer/geometry/Painter.js +++ b/src/renderer/geometry/Painter.js @@ -594,7 +594,7 @@ class Painter extends Class { return; } //Multiplexing offset - this.containerOffset = offset || mapStateCache.offset || map._pointToContainerPoint(renderer.southWest)._add(0, -map.height); + this.containerOffset = offset || mapStateCache.offset || map._pointToContainerPoint(renderer.middleWest)._add(0, -map.height / 2); this._beforePaint(); const ctx = context || renderer.context; if (!ctx.isHitTesting) { diff --git a/src/renderer/layer/CanvasRenderer.js b/src/renderer/layer/CanvasRenderer.js index 3a8e99a0a..7d0c9f761 100644 --- a/src/renderer/layer/CanvasRenderer.js +++ b/src/renderer/layer/CanvasRenderer.js @@ -218,7 +218,7 @@ class CanvasRenderer extends Class { remove() { this.onRemove(); delete this._loadingResource; - delete this.southWest; + delete this.middleWest; delete this.canvas; delete this.context; delete this.canvasExtent2D; @@ -266,7 +266,7 @@ class CanvasRenderer extends Class { return null; } // size = this._extent2D.getSize(), - const containerPoint = map._pointToContainerPoint(this.southWest)._add(0, -map.height); + const containerPoint = map._pointToContainerPoint(this.middleWest)._add(0, -map.height / 2); return { 'image': this.canvas, 'layer': this.layer, @@ -392,7 +392,7 @@ class CanvasRenderer extends Class { /** * Prepare rendering - * Set necessary properties, like this._renderZoom/ this.canvasExtent2D, this.southWest + * Set necessary properties, like this._renderZoom/ this.canvasExtent2D, this.middleWest * @private */ prepareRender() { @@ -400,8 +400,8 @@ class CanvasRenderer extends Class { const map = this.getMap(); this._renderZoom = map.getZoom(); this.canvasExtent2D = this._extent2D = map._get2DExtent(); - //change from northWest to southWest, because northwest's point <=> containerPoint changes when pitch >= 72 - this.southWest = map._containerPointToPoint(new Point(0, map.height)); + //change from northWest to middleWest, because northwest's point <=> containerPoint changes when pitch >= 72 + this.middleWest = map._containerPointToPoint(new Point(0, map.height / 2)); } /** @@ -575,10 +575,10 @@ class CanvasRenderer extends Class { if (!mask) { return false; } - const old = this.southWest; + const old = this.middleWest; const map = this.getMap(); - //when clipping, layer's southwest needs to be reset for mask's containerPoint conversion - this.southWest = map._containerPointToPoint(new Point(0, map.height)); + //when clipping, layer's middleWest needs to be reset for mask's containerPoint conversion + this.middleWest = map._containerPointToPoint(new Point(0, map.height / 2)); context.save(); const dpr = map.getDevicePixelRatio(); if (dpr !== 1) { @@ -607,20 +607,20 @@ class CanvasRenderer extends Class { context.restore(); } context.clip(); - this.southWest = old; + this.middleWest = old; return true; } /** * Get renderer's current view extent in 2d point - * @return {Object} view.extent, view.maskExtent, view.zoom, view.southWest + * @return {Object} view.extent, view.maskExtent, view.zoom, view.middleWest */ getViewExtent() { return { 'extent': this._extent2D, 'maskExtent': this._maskExtent, 'zoom': this._renderZoom, - 'southWest': this.southWest + 'middleWest': this.middleWest }; } diff --git a/src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.js b/src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.js index fe91cd768..4d9185d90 100644 --- a/src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.js +++ b/src/renderer/layer/vectorlayer/VectorLayerCanvasRenderer.js @@ -401,7 +401,7 @@ class VectorLayerRenderer extends OverlayLayerCanvasRenderer { _updateMapStateCache() { const map = this.getMap(); - const offset = map._pointToContainerPoint(this.southWest)._add(0, -map.height); + const offset = map._pointToContainerPoint(this.middleWest)._add(0, -map.height / 2); const resolution = map.getResolution(); const pitch = map.getPitch(); const bearing = map.getBearing(); diff --git a/test/layer/CanvasLayerSpec.js b/test/layer/CanvasLayerSpec.js index a36e8437d..95d29dd86 100644 --- a/test/layer/CanvasLayerSpec.js +++ b/test/layer/CanvasLayerSpec.js @@ -32,7 +32,7 @@ describe('Layer.CanvasLayer', function () { layer.draw = function (context, view, w, h) { expect(view.extent.isValid()).to.be.ok(); - expect(view.southWest).to.be.ok(); + expect(view.middleWest).to.be.ok(); expect(view.zoom).to.be.eql(map.getZoom()); expect(w).to.be.eql(size.width); expect(h).to.be.eql(size.height); diff --git a/test/map/MapCameraSpec.js b/test/map/MapCameraSpec.js index a24fec991..7919f1953 100644 --- a/test/map/MapCameraSpec.js +++ b/test/map/MapCameraSpec.js @@ -379,7 +379,7 @@ describe('Map.Camera', function () { map.setPitch(70); var size3 = geometry.getSize(); - expect(size3.width).to.be.above(size2.width); + expect(size2.width).to.be.above(size3.width); expect(size3.height).to.be.below(size2.height); }); }); @@ -455,7 +455,7 @@ describe('Map.Camera', function () { describe('Set camera position', function () { it('pitch 0, bearing 0', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 10000], pitch: 0, bearing: 0, @@ -468,7 +468,7 @@ describe('Map.Camera', function () { }); it('pitch 45, bearing 45', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 10000], pitch: 45, bearing: 45, @@ -481,7 +481,7 @@ describe('Map.Camera', function () { }); it('pitch 45, bearing 135', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 10000], pitch: 45, bearing: 135, @@ -494,7 +494,7 @@ describe('Map.Camera', function () { }); it('pitch 45, bearing -45', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 10000], pitch: 45, bearing: -45, @@ -507,7 +507,7 @@ describe('Map.Camera', function () { }); it('pitch 45, bearing -135', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 10000], pitch: 45, bearing: -135, @@ -520,7 +520,7 @@ describe('Map.Camera', function () { }); it('position z', function () { - map.setCameraPosition({ + map.setCameraOrientation({ position: [0, 0, 100], pitch: 0, bearing: 0, @@ -629,5 +629,17 @@ describe('Map.Camera', function () { // expect(maptalks.Util.join(map.domCssMatrix)).to.be.eql([31.819805153394643, -8.235571585149868, 0.7139488752261732, 0.6830127018922193, 31.819805153394636, 8.23557158514987, -0.7139488752261733, -0.6830127018922194, 0, -43.466662183008076, -0.27054191763364316, -0.25881904510252074, 0, 0, 46.83368719036461, 45].join()); expect(maptalks.Util.join(map.domCssMatrix)).to.be.eql([31.819805153394643,-8.235571585149868,0.693731297039628,0.6830127018922193,31.819805153394636,8.23557158514987,-0.6937312970396281,-0.6830127018922194,0,-43.466662183008076,-0.2628807214860012,-0.25881904510252074,0,0,45.635325850044154,45].join()); }); + + it('setCameraPosition', function() { + const center = map.getCenter(); + const position = new maptalks.Coordinate(center.x + 0.01, center.y + 0.01, 100); + map.setCameraPosition(position); + const zoom = map.getZoom(); + const pitch = map.getPitch(); + const bearing = map.getBearing(); + expect(zoom).to.be.eql(14.899641034986649); + expect(pitch).to.be.eql(85.67228588474566); + expect(bearing).to.be.eql(139.8095157874954); + }); }); diff --git a/test/map/MapSpec.js b/test/map/MapSpec.js index 004cb3635..ca524f458 100644 --- a/test/map/MapSpec.js +++ b/test/map/MapSpec.js @@ -555,6 +555,7 @@ describe('Map.Spec', function () { map._getRenderer()._checkSizeInterval = 10; // this.timeout(map._getRenderer()._checkSizeInterval * 3); var center = map.getCenter(); + center.z = center.z || 0; map.once('resize', function (param) { expect(param).to.be.ok(); //center remains @@ -918,4 +919,12 @@ describe('Map.Spec', function () { done(); }, 100); }); + + it('map\'s center has altitude', function() { + const center = map.getCenter(); + center.z = 100; + map.setCenter(center); + const viewMatrix = map.viewMatrix; + expect(viewMatrix).to.be.eql([-1, 0, 0, -0, 0, 1, 0, 0, 0, 0, -1, 0, 173083.2338488889, -49314.063792176465, 0.0703125, 1]); + }); }); diff --git a/test/map/MapViewHistorySpec.js b/test/map/MapViewHistorySpec.js index f279ebdef..343c7e12f 100644 --- a/test/map/MapViewHistorySpec.js +++ b/test/map/MapViewHistorySpec.js @@ -57,7 +57,7 @@ describe('Map View History', function () { renderer.callInNextFrame(function () { map.zoomToPreviousView(); var next = map.zoomToNextView(); - expect(next.center).to.be.eql([0, 0]); + expect(next.center).to.be.eql([0, 0, 0]); expect(next.zoom).to.be.eql(zoom - 1); expect(map.hasNextView()).not.to.be.ok(); diff --git a/test/map/control/Control.OverviewSpec.js b/test/map/control/Control.OverviewSpec.js index a9ea70f30..ac65ded69 100644 --- a/test/map/control/Control.OverviewSpec.js +++ b/test/map/control/Control.OverviewSpec.js @@ -71,7 +71,7 @@ describe('Control.Overview', function () { var overview = new maptalks.control.Overview(); overview.addTo(map); map.on('viewchange', function () { - expect(overview._overview.getCenter().toArray()).to.be.eql([0, 0]); + expect(overview._overview.getCenter().toArray()).to.be.eql([0, 0, 0]); done(); }); map.setCenter([0, 0]); diff --git a/test/map/control/Control.ResetSpec.js b/test/map/control/Control.ResetSpec.js index 44ab724c8..7140e2df4 100644 --- a/test/map/control/Control.ResetSpec.js +++ b/test/map/control/Control.ResetSpec.js @@ -37,7 +37,7 @@ describe('Control.Reset', function () { happen.click(control._reset); expect(map.getView()).to.eql({ - center: [120, 20], + center: [120, 20, 0], zoom: 8, bearing: 10, pitch: 30 @@ -51,7 +51,7 @@ describe('Control.Reset', function () { happen.click(control._reset); expect(map.getView()).to.eql({ - center: [118, 32], + center: [118, 32, 0], zoom: 5, bearing: 0, pitch: 0 @@ -63,7 +63,7 @@ describe('Control.Reset', function () { map.addControl(control); control.setView({ - center: [120, 20], + center: [120, 20, 0], zoom: 10, bearing: 2, pitch: 1 @@ -73,7 +73,7 @@ describe('Control.Reset', function () { map.once('viewchange', function () { expect(map.getView()).to.eql({ - center: [120, 20], + center: [120, 20, 0], zoom: 10, bearing: 2, pitch: 1