Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Add zoom animation, fix #20 #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/plugin/leaflet.canvas-markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function layerFactory(L) {

map.on('click', this._executeListeners, this);
map.on('mousemove', this._executeListeners, this);

if (map._zoomAnimated) {
map.on('zoomanim', this._animateZoom, this);
}
},

onRemove: function (map) {
Expand All @@ -141,6 +145,11 @@ function layerFactory(L) {

map.off('moveend', this._reset, this);
map.off('resize',this._reset,this);


if (map._zoomAnimated) {
map.off('zoomanim', this._animateZoom, this);
}
},

addTo: function (map) {
Expand All @@ -156,6 +165,13 @@ function layerFactory(L) {
this._redraw(true);
},

_animateZoom: function(event) {
var scale = this._map.getZoomScale(event.zoom);
var offset = this._map._latLngBoundsToNewLayerBounds(this._map.getBounds(), event.zoom, event.center).min;

L.DomUtil.setTransform(this._canvas, offset, scale);
},

_addMarker: function(marker,latlng,isDisplaying) {

var self = this;
Expand Down Expand Up @@ -346,8 +362,6 @@ function layerFactory(L) {
_initCanvas: function () {

this._canvas = L.DomUtil.create('canvas', 'leaflet-canvas-icon-layer leaflet-layer');
var originProp = L.DomUtil.testProp(['transformOrigin', 'WebkitTransformOrigin', 'msTransformOrigin']);
this._canvas.style[originProp] = '50% 50%';

var size = this._map.getSize();
this._canvas.width = size.x;
Expand Down