gLayers.Leaflet
generic map layers for leaflet 0.7 and 1.0-rc, moving from original GIST here https://gist.github.com/Sumbera/11114288 to this repo.
L.CanvasLayer - full screen generic canvas layer for leaflet
API
methods | description |
---|---|
needRedraw | will schedule next frame call for drawLayer |
delegate(object) | optionaly set receiver of the events if not 'inheriting' from L.CanvasLayer |
events | description |
---|---|
onLayerDidMount | after layer is attached/added to the map |
onLayerWillUnmount | before layer is removed from the map |
onDrawLayer(info) | when layer is drawn , info contains view parameters like bounds, size, canvas etc. |
note : events will be called only if presented on the 'subclass' or if delegate(receiver) is set
Examples
Basic usage
L // -- if we do not inherit from L.CanvasLayer we can setup a delegate to receive events from L.CanvasLayer ; { var ctx = infocanvas; ctx; ctxfillStyle = "rgba(255,116,0, 0.2)"; for var i = 0; i < datalength; i++ var d = datai; if infobounds dot = infolayer_map; ctx; ctx; ctx; ctx; };
Custom layer
{ this{ // -- prepare custom drawing }; this{ // -- custom cleanup }; this{ // -- custom data set this; // -- call to drawLayer }; this{ // -- custom draw } } myCustomCanvasDrawprototype = ; // -- setup prototype var myLayer = ; myLayer;
Other useful full view Leaflet Canvas sources here: