new CanvasLayer(id, options) [source]
var layer = new CanvasLayer('canvas');
layer.prepareToDraw = function (context) {
var size = map.getSize();
return [size.width, size.height]
};
layer.draw = function (context, width, height) {
context.fillStyle = "#f00";
context.fillRect(0, 0, w, h);
};
layer.addTo(map);
Parameter | Type | Description |
---|---|---|
id
|
String | Number | layer's id |
options
|
Object | options defined in options |
Extends:
Fires:
Members
(constant) options
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options
|
Object | configuration options
Properties
|
- Overrides:
- Source:
Methods
prepareToDraw(context) [source]
An optional interface function called only once before the first draw, useful for preparing your canvas operations.
Parameter | Type | Description |
---|---|---|
context
|
CanvasRenderingContext2D | CanvasRenderingContext2D of the layer canvas. |
Returns:
Array.<Object>: objects that will be passed to function draw(context, ..) as parameters.draw(context) [source]
The required interface function to draw things on the layer canvas.
Parameter | Type | Description |
---|---|---|
context
|
CanvasRenderingContext2D | CanvasRenderingContext2D of the layer canvas. |
params..
|
* | parameters returned by function prepareToDraw(context). |
redraw() [source]
Redraw the layer
Returns:
CanvasLayer: thisplay() [source]
Start animation
Returns:
CanvasLayer: thispause() [source]
Pause the animation
Returns:
CanvasLayer: thisisPlaying() [source]
If the animation is playing
Returns:
Boolean:clearCanvas() [source]
Clear layer's canvas
Returns:
CanvasLayer: thisrequestMapToRender() [source]
Ask the map to redraw the layer canvas without firing any event.
Returns:
CanvasLayer: thiscompleteRender() [source]
Ask the map to redraw the layer canvas and fire layerload event
Returns:
CanvasLayer: thisonCanvasCreate() [source]
Callback function when layer's canvas is created.
Override it to do anything needed.
Override it to do anything needed.
onZoomStart(param) [source]
The event callback for map's zoomstart event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onZooming(param) [source]
The event callback for map's zooming event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onZoomEnd(param) [source]
The event callback for map's zoomend event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onMoveStart(param) [source]
The event callback for map's movestart event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onMoving(param) [source]
The event callback for map's moving event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onMoveEnd(param) [source]
The event callback for map's moveend event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
onResize(param) [source]
The event callback for map's resize event.
Parameter | Type | Description |
---|---|---|
param
|
Object | event parameter |
doubleBuffer(bufferContext, context) [source]
The callback function to double buffer.
In default, it just draws and return, and you can override it if you need to process the canvas image before drawn.
In default, it just draws and return, and you can override it if you need to process the canvas image before drawn.
Parameter | Type | Description |
---|---|---|
bufferContext
|
CanvasRenderingContext2D | CanvasRenderingContext2D of double buffer of the layer canvas. |
context
|
CanvasRenderingContext2D | CanvasRenderingContext2D of the layer canvas. |
(inherited) load() [source]
load the tile layer, can't be overrided by sub-classes
Inherited From:
(inherited) getId() [source]
Get the layer id
Inherited From:
Returns:
String: id(inherited) setId(id) [source]
Set a new id to the layer
Parameter | Type | Description |
---|---|---|
id
|
String | new layer id |
Inherited From:
Fires:
Returns:
Layer: this(inherited) addTo(map) [source]
Adds itself to a map.
Parameter | Type | Description |
---|---|---|
map
|
Map | map added to |
Inherited From:
Returns:
Layer: this(inherited) setZIndex(zIndex) [source]
Set a z-index to the layer
Parameter | Type | Description |
---|---|---|
zIndex
|
Number | layer's z-index |
Inherited From:
Returns:
Layer: this(inherited) getZIndex() [source]
Get the layer's z-index
Inherited From:
Returns:
Number:(inherited) getMinZoom() [source]
Get Layer's minZoom to display
Inherited From:
Returns:
Number:(inherited) getMaxZoom() [source]
Get Layer's maxZoom to display
Inherited From:
Returns:
Number:(inherited) getOpacity() [source]
Get layer's opacity
Inherited From:
Returns:
Number:(inherited) setOpacity(opacity) [source]
Set opacity to the layer
Parameter | Type | Description |
---|---|---|
opacity
|
Number | layer's opacity |
Inherited From:
Returns:
Layer: this(protected) (inherited) isCanvasRender() [source]
If the layer is rendered by HTML5 Canvas.
Returns:
Boolean:(inherited) getMap() [source]
Get the map that the layer added to
Inherited From:
Returns:
Map:(inherited) getProjection() [source]
Get projection of layer's map
Inherited From:
Returns:
Object:(inherited) bringToFront() [source]
Brings the layer to the top of all the layers
Inherited From:
Returns:
Layer: this(inherited) bringToBack() [source]
Brings the layer under the bottom of all the layers
Inherited From:
Returns:
Layer: this(inherited) show() [source]
Show the layer
Inherited From:
Returns:
Layer: this(inherited) hide() [source]
Hide the layer
Inherited From:
Returns:
Layer: this(inherited) isVisible() [source]
Whether the layer is visible now.
Inherited From:
Returns:
Boolean:(inherited) remove() [source]
Remove itself from the map added to.
Inherited From:
Returns:
Layer: this(inherited) getMask() [source]
Get the mask geometry of the layer
Inherited From:
Returns:
Geometry:(inherited) setMask(mask) [source]
Set a mask geometry on the layer, only the area in the mask will be displayed.
Parameter | Type | Description |
---|---|---|
mask
|
Geometry | mask geometry, can only be a Marker with vector symbol, a Polygon or a MultiPolygon |
Inherited From:
Returns:
Layer: this(inherited) removeMask() [source]
Remove the mask
Inherited From:
Returns:
Layer: this(protected) (inherited) onLoad() [source]
Prepare Layer's loading, this is a method intended to be overrided by subclasses.
Inherited From:
Returns:
Boolean: true to continue loading, false to cease.(inherited) isLoaded() [source]
Whether the layer is loaded
Inherited From:
Returns:
Boolean:(inherited) 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:
Inherited From:
Returns:
Any: this(inherited) 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:
Inherited From:
Returns:
: this(inherited) 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:
Inherited From:
Returns:
: this(inherited) 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:
Inherited From:
Returns:
: this(inherited) 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:
Inherited From:
Returns:
: this(inherited) 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:
Inherited From:
Returns:
Number:(inherited) copyEventListeners(target) [source]
Copy all the event listener to the target object
Parameter | Type | Description |
---|---|---|
target
|
Object | target object to copy to. |
Mixes From:
Inherited From:
Returns:
: this(inherited) 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:
Inherited From:
Returns:
: this(inherited) registerJSONType(type) [source]
It is a static method.
Register layer for JSON serialization and assign a JSON type.
Register layer for JSON serialization and assign a JSON type.
Parameter | Type | Description |
---|---|---|
type
|
String | JSON type |
Mixes From:
Inherited From:
(inherited) getJSONClass(type) [source]
It is a static method.
Get class of input JSON type
Get class of input JSON type
Parameter | Type | Description |
---|---|---|
type
|
String | JSON type |
Mixes From:
Inherited From:
Returns:
Class: Class(inherited) getJSONType() [source]
Get object's JSON Type
Mixes From:
Inherited From:
Returns:
String:(inherited) 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:
Inherited From:
Returns:
*: this(inherited) getRendererClass(name) [source]
Get the registered renderer class by the given name
Parameter | Type | Description |
---|---|---|
name
|
String | renderer's register key |
Mixes From:
Inherited 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.
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(inherited) onConfig() [source]
Default callback when config is called
Inherited From:
Events
(inherited) idchange [source]
idchange event.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | idchange |
target
|
Layer | the layer fires the event |
old
|
String | value of the old id |
new
|
String | value of the new id |
- Inherited From:
- Source:
(inherited) renderercreate [source]
renderercreate event, fired when renderer is created.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | renderercreate |
target
|
Layer | the layer fires the event |
renderer
|
Any | renderer of the layer |
- Inherited From:
- Source:
(inherited) resourceload [source]
resourceload event, fired when external resources of the layer complete loading.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | resourceload |
target
|
Layer | layer |
- Inherited From:
- Source:
(inherited) canvascreate [source]
canvascreate event, fired when canvas created.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | canvascreate |
target
|
Layer | layer |
context
|
CanvasRenderingContext2D | canvas's context |
gl
|
WebGLRenderingContext2D | canvas's webgl context |
- Inherited From:
- Source:
(inherited) renderstart [source]
renderstart event, fired when layer starts to render.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | renderstart |
target
|
Layer | layer |
context
|
CanvasRenderingContext2D | canvas's context |
- Inherited From:
- Source:
(inherited) renderend [source]
renderend event, fired when layer ends rendering.
Inherited From:
Properties:
Name | Type | Description |
---|---|---|
type
|
String | renderend |
target
|
Layer | layer |
context
|
CanvasRenderingContext2D | canvas's context |
- Inherited From:
- Source: