Skip to content

Commit 3e340db

Browse files
Stanislav Sviridi.taratuhin
authored andcommitted
update leaflet version
1 parent e595302 commit 3e340db

12 files changed

Lines changed: 95 additions & 49 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#6998a11da56a796a8bbee34f00705e264ec41ff8",
5858
"less": "^2.4.0",
5959
"lodash": "^2.4.1",
6060
"map-stream": "0.1.0",

src/DGCustomization/src/DGCustomization.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ DG.setOptions = L.setOptions = DG.Util.setOptions = function (obj, options) {
2626

2727
return utilSetOptions.call(this, obj, options);
2828
};
29+
30+
DG.Layer.mergeOptions({
31+
nonBubblingEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu']
32+
});

src/DGCustomization/src/DGMap.js

Lines changed: 53 additions & 11 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 = {};
@@ -181,30 +185,68 @@ DG.Map.include({
181185

182186
// Add prepreclick event before preclick than geoclicker can track popup state
183187
// https://github.com/2gis/mapsapi/pull/96
184-
_fireDOMEvent: function (target, e, type) {
185-
if (!target.listens(type, true) && (type !== 'click' || !target.listens('preclick', true))) { return; }
188+
_handleDOMEvent: function (e) {
189+
if (!this._loaded || L.DomEvent._skipped(e)) { return; }
190+
191+
// find the layer the event is propagating from and its parents
192+
var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
193+
194+
if (e.type === 'click') {
195+
// Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).
196+
var synthPrePre = L.Util.extend({}, e);
197+
synthPrePre.type = 'prepreclick';
198+
this._handleDOMEvent(synthPrePre);
199+
200+
var synth = L.Util.extend({}, e);
201+
synth.type = 'preclick';
202+
this._handleDOMEvent(synth);
203+
}
204+
205+
if (type === 'mousedown') {
206+
// prevents outline when clicking on keyboard-focusable element
207+
L.DomUtil.preventOutline(e.target || e.srcElement);
208+
}
186209

187-
if (type === 'contextmenu') {
210+
this._fireDOMEvent(e, type);
211+
},
212+
213+
_fireDOMEvent: function (e, type, targets) {
214+
215+
var isHover = type === 'mouseover' || type === 'mouseout';
216+
targets = (targets || []).concat(this._findEventTargets(e.target || e.srcElement, type, !isHover));
217+
218+
if (!targets.length) {
219+
targets = [this];
220+
221+
// special case for map mouseover/mouseout events so that they're actually mouseenter/mouseleave
222+
if (isHover && !L.DomEvent._checkMouse(this._container, e)) { return; }
223+
} else if (type === 'contextmenu') {
224+
// we only want to call preventDefault when targets listen to it.
188225
L.DomEvent.preventDefault(e);
189226
}
190227

228+
var target = targets[0];
229+
191230
// prevents firing click after you just dragged an object
192-
if (e.type === 'click' && !e._simulated && this._draggableMoved(target)) { return; }
231+
if ((e.type === 'click' || e.type === 'preclick' || e.type === 'prepreclick') && !e._simulated && this._draggableMoved(target)) { return; }
193232

194233
var data = {
195234
originalEvent: e
196235
};
236+
197237
if (e.type !== 'keypress') {
198-
data.containerPoint = target instanceof L.Marker ?
199-
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
238+
var isMarker = target instanceof L.Marker;
239+
data.containerPoint = isMarker ?
240+
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
200241
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
201-
data.latlng = this.layerPointToLatLng(data.layerPoint);
242+
data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);
202243
}
203-
if (type === 'click') {
204-
target.fire('prepreclick', data, true);
205-
target.fire('preclick', data, true);
244+
245+
for (var i = 0; i < targets.length; i++) {
246+
targets[i].fire(type, data, true);
247+
if (data.originalEvent._stopped
248+
|| (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }
206249
}
207-
target.fire(type, data, true);
208250
}
209251
});
210252

src/DGCustomization/test/GridLayerSpec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ describe('GridLayer', function () {
5757
}
5858

5959
expect(loaded).to.eql({
60-
'144:44': [0, 0],
61-
'400:44': [1, 0],
62-
'144:300': [0, 1],
63-
'400:300': [1, 1],
64-
'-112:44': [1, 0],
65-
'656:44': [0, 0],
66-
'-112:300': [1, 1],
67-
'656:300': [0, 1]
60+
'144:0': [0, 0],
61+
'400:0': [1, 0],
62+
'144:256': [0, 1],
63+
'400:256': [1, 1],
64+
'-112:0': [1, 0],
65+
'656:0': [0, 0],
66+
'-112:256': [1, 1],
67+
'656:256': [0, 1]
6868
});
6969
});
7070

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/DGProjectDetector/test/ProjectDetectorInSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,21 @@ describe('DG.ProjectDetectorIn', function () {
238238
map.setView(project1, maxZoom);
239239

240240
expect(map.fitWorld()).to.be(map);
241-
expect(map.getZoom()).to.be(0);
241+
expect(map.getZoom()).to.be(1);
242242
});
243243

244244
it('fire from min zoom', function () {
245245
map.setView(project1, 0);
246246

247247
expect(map.fitWorld()).to.be(map);
248-
expect(map.getZoom()).to.be(0);
248+
expect(map.getZoom()).to.be(1);
249249
});
250250

251251
it('fire after min zoom 15', function () {
252252
map.setZoom(15);
253253

254254
expect(map.fitWorld()).to.be(map);
255-
expect(map.getZoom()).to.be(0);
255+
expect(map.getZoom()).to.be(1);
256256
});
257257
});
258258

src/DGProjectDetector/test/ProjectDetectorOutOfWorldSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,21 @@ describe('DG.ProjectDetectorOut', function () {
238238
map.setView(project1, maxZoom);
239239

240240
expect(map.fitWorld()).to.be(map);
241-
expect(map.getZoom()).to.be(0);
241+
expect(map.getZoom()).to.be(1);
242242
});
243243

244244
it('fire from min zoom', function () {
245245
map.setView(project1, 0);
246246

247247
expect(map.fitWorld()).to.be(map);
248-
expect(map.getZoom()).to.be(0);
248+
expect(map.getZoom()).to.be(1);
249249
});
250250

251251
it('fire after min zoom 15', function () {
252252
map.setZoom(15);
253253

254254
expect(map.fitWorld()).to.be(map);
255-
expect(map.getZoom()).to.be(0);
255+
expect(map.getZoom()).to.be(1);
256256
});
257257
});
258258

src/DGProjectDetector/test/ProjectDetectorUnderSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,21 +238,21 @@ describe('DG.ProjectDetectorUnder', function () {
238238
map.setView(project1, maxZoom);
239239

240240
expect(map.fitWorld()).to.be(map);
241-
expect(map.getZoom()).to.be(0);
241+
expect(map.getZoom()).to.be(1);
242242
});
243243

244244
it('fire from min zoom', function () {
245245
map.setView(project1, 0);
246246

247247
expect(map.fitWorld()).to.be(map);
248-
expect(map.getZoom()).to.be(0);
248+
expect(map.getZoom()).to.be(1);
249249
});
250250

251251
it('fire after min zoom 15', function () {
252252
map.setZoom(15);
253253

254254
expect(map.fitWorld()).to.be(map);
255-
expect(map.getZoom()).to.be(0);
255+
expect(map.getZoom()).to.be(1);
256256
});
257257
});
258258

0 commit comments

Comments
 (0)