Zooming now works properly
The initial zoom level is 10 and it goes to: 1, which is 10% and 20, which is 200%private/hcvcastro/forking
parent
9ecc37d433
commit
2aa7f55ea8
|
@ -32,9 +32,9 @@
|
|||
|
||||
var map = L.map('map', 'document-container', {
|
||||
center: [0, 0],
|
||||
zoom: 5,
|
||||
zoom: 10,
|
||||
minZoom: 1,
|
||||
maxZoom: 10,
|
||||
maxZoom: 20,
|
||||
server: "ws://localhost:9980",
|
||||
dragging: false,
|
||||
topLeft: new L.Point([0, 0]),
|
||||
|
|
|
@ -7,7 +7,7 @@ L.CRS.Simple = L.extend({}, L.CRS, {
|
|||
transformation: new L.Transformation(1, 0, -1, 0),
|
||||
|
||||
scale: function (zoom) {
|
||||
return Math.pow(2, zoom);
|
||||
return zoom / 10;
|
||||
},
|
||||
|
||||
distance: function (latlng1, latlng2) {
|
||||
|
|
|
@ -324,7 +324,7 @@ L.GridLayer = L.Layer.extend({
|
|||
|
||||
this._tileZoom = tileZoom;
|
||||
if (tileZoomChanged) {
|
||||
this._updateTileTwips(this._map.options.zoom - tileZoom);
|
||||
this._updateTileTwips();
|
||||
this._updateMaxBounds();
|
||||
}
|
||||
this._updateLevels();
|
||||
|
@ -342,10 +342,11 @@ L.GridLayer = L.Layer.extend({
|
|||
this._setZoomTransforms(center, zoom);
|
||||
},
|
||||
|
||||
_updateTileTwips: function (difference) {
|
||||
// zoom by 20%
|
||||
this._tileWidthTwips = Math.round(this.options.tileWidthTwips * (1 + difference * 0.2));
|
||||
this._tileHeightTwips = Math.round(this.options.tileHeightTwips * (1 + difference * 0.2));
|
||||
_updateTileTwips: function () {
|
||||
// smaller zoom = zoom in
|
||||
var factor = 1 + (10 - this._tileZoom) / 10;
|
||||
this._tileWidthTwips = Math.round(this.options.tileWidthTwips * factor);
|
||||
this._tileHeightTwips = Math.round(this.options.tileHeightTwips * factor);
|
||||
},
|
||||
|
||||
_updateMaxBounds: function () {
|
||||
|
|
Loading…
Reference in New Issue