Skip to content

Commit 0c070e3

Browse files
author
Stanislav Svirid
committed
update leaflet version
1 parent ab58ee2 commit 0c070e3

6 files changed

Lines changed: 43 additions & 40 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"happen": "0.1.3",
5555
"html5shiv": "^3.7.2",
5656
"image-size": "0.3.5",
57-
"leaflet": "git://github.com/Leaflet/Leaflet.git#1bb1b5a3f8307b4460211f340281b764a24a13cc",
57+
"leaflet": "git://github.com/Leaflet/Leaflet.git#d2513b2d53ba64217b61456844e7c47f6bb9ef65",
5858
"less": "^2.4.0",
5959
"lodash": "^2.4.1",
6060
"map-stream": "0.1.0",

src/DGCustomization/src/DGMap.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ DG.Map.include({
2525
this.setMaxBounds(options.maxBounds);
2626
}
2727

28+
if (options.zoom !== undefined) {
29+
this._zoom = this._limitZoom(options.zoom);
30+
}
31+
2832
this._handlers = [];
2933

3034
this._layers = {};
@@ -164,30 +168,29 @@ DG.Map.include({
164168

165169
// Add prepreclick event before preclick than geoclicker can track popup state
166170
// https://github.com/2gis/mapsapi/pull/96
167-
_fireDOMEvent: function (target, e, type) {
168-
if (!target.listens(type, true) && (type !== 'click' || !target.listens('preclick', true))) { return; }
171+
_handleDOMEvent: function (e) {
172+
if (!this._loaded || L.DomEvent._skipped(e)) { return; }
169173

170-
if (type === 'contextmenu') {
171-
L.DomEvent.preventDefault(e);
172-
}
174+
// find the layer the event is propagating from and its parents
175+
var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
173176

174-
// prevents firing click after you just dragged an object
175-
if (e.type === 'click' && !e._simulated && this._draggableMoved(target)) { return; }
176-
177-
var data = {
178-
originalEvent: e
179-
};
180-
if (e.type !== 'keypress') {
181-
data.containerPoint = target instanceof L.Marker ?
182-
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
183-
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
184-
data.latlng = this.layerPointToLatLng(data.layerPoint);
177+
if (e.type === 'click') {
178+
// Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).
179+
var synthPrePre = L.Util.extend({}, e);
180+
synthPrePre.type = 'prepreclick';
181+
this._handleDOMEvent(synthPrePre);
182+
183+
var synth = L.Util.extend({}, e);
184+
synth.type = 'preclick';
185+
this._handleDOMEvent(synth);
185186
}
186-
if (type === 'click') {
187-
target.fire('prepreclick', data, true);
188-
target.fire('preclick', data, true);
187+
188+
if (type === 'mousedown') {
189+
// prevents outline when clicking on keyboard-focusable element
190+
L.DomUtil.preventOutline(e.target || e.srcElement);
189191
}
190-
target.fire(type, data, true);
192+
193+
this._fireDOMEvent(e, type);
191194
}
192195
});
193196

src/DGMeta/src/DGMeta.Layer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DG.Meta.Layer = DG.Layer.extend({
6767

6868
_removeAllTiles: DG.GridLayer.prototype._removeAllTiles,
6969
_getZoomForUrl: DG.TileLayer.prototype._getZoomForUrl,
70-
_getTileSize: DG.TileLayer.prototype._getTileSize,
70+
getTileSize: DG.TileLayer.prototype.getTileSize,
7171
_isValidTile: DG.GridLayer.prototype._isValidTile,
7272
_wrapCoords: DG.GridLayer.prototype._wrapCoords,
7373
_resetView: DG.GridLayer.prototype._resetView,
@@ -77,10 +77,10 @@ DG.Meta.Layer = DG.Layer.extend({
7777

7878
_domEvents: {
7979
mousemove: function (event) { // (MouseEvent)
80-
var tileSize = this._getTileSize(),
80+
var tileSize = this.getTileSize(),
8181
layerPoint = this._map.mouseEventToLayerPoint(event),
8282
tileOriginPoint = this._map.getPixelOrigin().add(layerPoint),
83-
tileCoord = tileOriginPoint.divideBy(tileSize).floor(),
83+
tileCoord = tileOriginPoint.unscaleBy(tileSize).floor(),
8484
mouseTileOffset,
8585
tileKey,
8686
hoveredObject,
@@ -95,7 +95,7 @@ DG.Meta.Layer = DG.Layer.extend({
9595
this._wrapCoords(tileCoord);
9696

9797
tileCoord.z = this._getZoomForUrl();
98-
tileCoord.key = tileSize;
98+
tileCoord.key = tileSize.x + 'x' + tileSize.y;
9999
tileKey = this._origin.getTileKey(tileCoord);
100100

101101
if (tileKey !== this._currentTile) {
@@ -106,7 +106,7 @@ DG.Meta.Layer = DG.Layer.extend({
106106
if (this._currentTileData === false) {
107107
this._currentTileData = this._origin.getTileData(tileCoord);
108108
} else {
109-
mouseTileOffset = DG.point(tileOriginPoint.x % tileSize, tileOriginPoint.y % tileSize);
109+
mouseTileOffset = DG.point(tileOriginPoint.x % tileSize.x, tileOriginPoint.y % tileSize.y);
110110
hoveredObject = this._getHoveredObject(tileCoord, mouseTileOffset);
111111

112112
if (this._hoveredEntity !== hoveredObject) {

src/DGMeta/test/DGMetaSpec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('DGMeta', function () {
5555
});
5656

5757
it('should click on map', function () {
58-
origin.setTileData('78713:43453:17:256', demoData);
58+
origin.setTileData('78713:43453:17:256x256', demoData);
5959
spy = sinon.spy();
6060
meta.addTo(map);
6161

@@ -71,7 +71,7 @@ describe('DGMeta', function () {
7171
it('getTileData should NOT call ajax and return false', function () {
7272
var data;
7373

74-
data = origin.getTileData('124:12:42:256');
74+
data = origin.getTileData('124:12:42:256x256');
7575

7676
expect(data).to.not.be.ok();
7777
//ajax should not be called since empty url provided
@@ -81,9 +81,9 @@ describe('DGMeta', function () {
8181
it('flush should clear cache', function () {
8282
var chain, data;
8383

84-
origin.setTileData({x: 124, y: 12, z: 42, key: 256}, demoData);
84+
origin.setTileData({x: 124, y: 12, z: 42, key: '256x256'}, demoData);
8585
chain = origin.flush();
86-
data = origin.getTileData({x: 124, y: 12, z: 42, key: 256});
86+
data = origin.getTileData({x: 124, y: 12, z: 42, key: '256x256'});
8787

8888
expect(data).to.not.be.ok();
8989
// check for returning this
@@ -98,7 +98,7 @@ describe('DGMeta', function () {
9898
data, chain;
9999

100100
chain = origin.setURL('http://demo/data');
101-
data = origin.getTileData({x: 124, y: 12, z: 42, key: 256});
101+
data = origin.getTileData({x: 124, y: 12, z: 42, key: '256x256'});
102102

103103
expect(data).to.not.be.ok();
104104
expect(ajaxSpy.callCount).to.be.eql(1);
@@ -126,7 +126,7 @@ describe('DGMeta', function () {
126126
var data;
127127

128128
origin.setURL('http://demo/data');
129-
data = origin.getTileData({x: 124, y: 12, z: 42, key: 256});
129+
data = origin.getTileData({x: 124, y: 12, z: 42, key: '256x256'});
130130

131131
expect(data).to.not.be.ok();
132132
expect(ajaxSpy.callCount).to.be.eql(1);
@@ -135,9 +135,9 @@ describe('DGMeta', function () {
135135
it('setTileData by object key should write and cache tileData', function () {
136136
var chain, data;
137137

138-
chain = origin.setTileData({x: 124, y: 12, z: 42, key: 256}, demoData);
138+
chain = origin.setTileData({x: 124, y: 12, z: 42, key: '256x256'}, demoData);
139139

140-
data = origin.getTileData({x: 124, y: 12, z: 42, key: 256});
140+
data = origin.getTileData({x: 124, y: 12, z: 42, key: '256x256'});
141141
expect(data).to.be.a('object');
142142
expect(ajaxSpy.callCount).to.be.eql(0);
143143
// check for returning this
@@ -147,9 +147,9 @@ describe('DGMeta', function () {
147147
it('setTileData by string key should write and cache tileData', function () {
148148
var chain, data;
149149

150-
chain = origin.setTileData('124:12:42:256', demoData);
150+
chain = origin.setTileData('124:12:42:256x256', demoData);
151151

152-
data = origin.getTileData({x: 124, y: 12, z: 42, key: 256});
152+
data = origin.getTileData({x: 124, y: 12, z: 42, key: '256x256'});
153153
expect(data).to.be.a('object');
154154
expect(ajaxSpy.callCount).to.be.eql(0);
155155
// check for returning this
@@ -159,9 +159,9 @@ describe('DGMeta', function () {
159159
it('getTileKey should string tileKey representation', function () {
160160
var tileKey;
161161

162-
tileKey = origin.getTileKey({x: 124, y: 12, z: 42, key: 256});
162+
tileKey = origin.getTileKey({x: 124, y: 12, z: 42, key: '256x256'});
163163

164-
expect(tileKey).to.be.eql('124:12:42:256');
164+
expect(tileKey).to.be.eql('124:12:42:256x256');
165165
});
166166
});
167167
});

src/DGPoi/src/DGPoi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ DG.Poi = DG.Handler.extend({
4343

4444
_processData : function (data, coord) {
4545
var map = this._map,
46-
tileOriginPoint = coord.multiplyBy(this._metaLayer._getTileSize());
46+
tileOriginPoint = coord.scaleBy(this._metaLayer.getTileSize());
4747

4848
if (data.responseText === '') {
4949
return [];

src/DGTraffic/src/DGTraffic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ DG.Traffic = DG.TileLayer.extend({
116116

117117
_processData: function (trafficData, coord) {
118118
var map = this._map,
119-
tileOriginPoint = coord.multiplyBy(this._getTileSize()),
119+
tileOriginPoint = coord.scaleBy(this.getTileSize()),
120120
hints = {};
121121

122122
if (!DG.Util.isArray(trafficData)) { // TODO remove

0 commit comments

Comments
 (0)