summaryrefslogtreecommitdiff
path: root/plugins/leaflet/scripts/leaflet-providers/preview/L.Map.Sync.js
blob: 2fa0953941665dbe7ba849c0da03e78e5d67c451 (plain)
1
2
3
(function(){L.Map=L.Map.extend({sync:function(a,b){this._initSync();var b=b||{},c=!1;this._syncMaps.forEach(function(b){a===b&&(c=!0)});c||this._syncMaps.push(a);b.noInitialSync||a.setView(this.getCenter(),this.getZoom(),{animate:!1,reset:!0});return this},unsync:function(a){var b=this;this._syncMaps&&this._syncMaps.forEach(function(c,d){a===c&&b._syncMaps.splice(d,1)});return this},_initSync:function(){if(!this._syncMaps){var a=this;this._syncMaps=[];L.extend(a,{setView:function(b,c,d,e){e||a._syncMaps.forEach(function(a){a.setView(b,
c,d,!0)});return L.Map.prototype.setView.call(this,b,c,d)},panBy:function(b,c,d){d||a._syncMaps.forEach(function(a){a.panBy(b,c,!0)});return L.Map.prototype.panBy.call(this,b,c)},_onResize:function(b,c){c||a._syncMaps.forEach(function(a){a._onResize(b,!0)});return L.Map.prototype._onResize.call(this,b)}});a.on("zoomend",function(){a._syncMaps.forEach(function(b){b.setView(a.getCenter(),a.getZoom(),{animate:!1,reset:!1})})},this);a.dragging._draggable._updatePosition=function(){L.Draggable.prototype._updatePosition.call(this);
var b=this;a._syncMaps.forEach(function(a){L.DomUtil.setPosition(a.dragging._draggable._element,b._newPos);a.fire("moveend")})}}}})})();