Skip to content

Commit

Permalink
update leaflet version
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Svirid authored and i.taratuhin committed Aug 25, 2015
1 parent e595302 commit 3e340db
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"happen": "0.1.3",
"html5shiv": "^3.7.2",
"image-size": "0.3.5",
"leaflet": "git://github.com/Leaflet/Leaflet.git#1bb1b5a3f8307b4460211f340281b764a24a13cc",
"leaflet": "git://github.com/Leaflet/Leaflet.git#6998a11da56a796a8bbee34f00705e264ec41ff8",
"less": "^2.4.0",
"lodash": "^2.4.1",
"map-stream": "0.1.0",
Expand Down
4 changes: 4 additions & 0 deletions src/DGCustomization/src/DGCustomization.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ DG.setOptions = L.setOptions = DG.Util.setOptions = function (obj, options) {

return utilSetOptions.call(this, obj, options);
};

DG.Layer.mergeOptions({
nonBubblingEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu']
});
64 changes: 53 additions & 11 deletions src/DGCustomization/src/DGMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ DG.Map.include({
this.setMaxBounds(options.maxBounds);
}

if (options.zoom !== undefined) {
this._zoom = this._limitZoom(options.zoom);
}

this._handlers = [];

this._layers = {};
Expand Down Expand Up @@ -181,30 +185,68 @@ DG.Map.include({

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

// find the layer the event is propagating from and its parents
var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;

if (e.type === 'click') {
// Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).
var synthPrePre = L.Util.extend({}, e);
synthPrePre.type = 'prepreclick';
this._handleDOMEvent(synthPrePre);

var synth = L.Util.extend({}, e);
synth.type = 'preclick';
this._handleDOMEvent(synth);
}

if (type === 'mousedown') {
// prevents outline when clicking on keyboard-focusable element
L.DomUtil.preventOutline(e.target || e.srcElement);
}

if (type === 'contextmenu') {
this._fireDOMEvent(e, type);
},

_fireDOMEvent: function (e, type, targets) {

var isHover = type === 'mouseover' || type === 'mouseout';
targets = (targets || []).concat(this._findEventTargets(e.target || e.srcElement, type, !isHover));

if (!targets.length) {
targets = [this];

// special case for map mouseover/mouseout events so that they're actually mouseenter/mouseleave
if (isHover && !L.DomEvent._checkMouse(this._container, e)) { return; }
} else if (type === 'contextmenu') {
// we only want to call preventDefault when targets listen to it.
L.DomEvent.preventDefault(e);
}

var target = targets[0];

// prevents firing click after you just dragged an object
if (e.type === 'click' && !e._simulated && this._draggableMoved(target)) { return; }
if ((e.type === 'click' || e.type === 'preclick' || e.type === 'prepreclick') && !e._simulated && this._draggableMoved(target)) { return; }

var data = {
originalEvent: e
};

if (e.type !== 'keypress') {
data.containerPoint = target instanceof L.Marker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
var isMarker = target instanceof L.Marker;
data.containerPoint = isMarker ?
this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
data.latlng = this.layerPointToLatLng(data.layerPoint);
data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint);
}
if (type === 'click') {
target.fire('prepreclick', data, true);
target.fire('preclick', data, true);

for (var i = 0; i < targets.length; i++) {
targets[i].fire(type, data, true);
if (data.originalEvent._stopped
|| (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }
}
target.fire(type, data, true);
}
});

Expand Down
16 changes: 8 additions & 8 deletions src/DGCustomization/test/GridLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ describe('GridLayer', function () {
}

expect(loaded).to.eql({
'144:44': [0, 0],
'400:44': [1, 0],
'144:300': [0, 1],
'400:300': [1, 1],
'-112:44': [1, 0],
'656:44': [0, 0],
'-112:300': [1, 1],
'656:300': [0, 1]
'144:0': [0, 0],
'400:0': [1, 0],
'144:256': [0, 1],
'400:256': [1, 1],
'-112:0': [1, 0],
'656:0': [0, 0],
'-112:256': [1, 1],
'656:256': [0, 1]
});
});

Expand Down
10 changes: 5 additions & 5 deletions src/DGMeta/src/DGMeta.Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ DG.Meta.Layer = DG.Layer.extend({

_removeAllTiles: DG.GridLayer.prototype._removeAllTiles,
_getZoomForUrl: DG.TileLayer.prototype._getZoomForUrl,
_getTileSize: DG.TileLayer.prototype._getTileSize,
getTileSize: DG.TileLayer.prototype.getTileSize,
_isValidTile: DG.GridLayer.prototype._isValidTile,
_wrapCoords: DG.GridLayer.prototype._wrapCoords,
_resetView: DG.GridLayer.prototype._resetView,
Expand All @@ -77,10 +77,10 @@ DG.Meta.Layer = DG.Layer.extend({

_domEvents: {
mousemove: function (event) { // (MouseEvent)
var tileSize = this._getTileSize(),
var tileSize = this.getTileSize(),
layerPoint = this._map.mouseEventToLayerPoint(event),
tileOriginPoint = this._map.getPixelOrigin().add(layerPoint),
tileCoord = tileOriginPoint.divideBy(tileSize).floor(),
tileCoord = tileOriginPoint.unscaleBy(tileSize).floor(),
mouseTileOffset,
tileKey,
hoveredObject,
Expand All @@ -95,7 +95,7 @@ DG.Meta.Layer = DG.Layer.extend({
this._wrapCoords(tileCoord);

tileCoord.z = this._getZoomForUrl();
tileCoord.key = tileSize;
tileCoord.key = tileSize.x + 'x' + tileSize.y;
tileKey = this._origin.getTileKey(tileCoord);

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

if (this._hoveredEntity !== hoveredObject) {
Expand Down
24 changes: 12 additions & 12 deletions src/DGMeta/test/DGMetaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('DGMeta', function () {
});

it('should click on map', function () {
origin.setTileData('78713:43453:17:256', demoData);
origin.setTileData('78713:43453:17:256x256', demoData);
spy = sinon.spy();
meta.addTo(map);

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

data = origin.getTileData('124:12:42:256');
data = origin.getTileData('124:12:42:256x256');

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

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

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

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

expect(data).to.not.be.ok();
expect(ajaxSpy.callCount).to.be.eql(1);
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('DGMeta', function () {
var data;

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

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

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

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

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

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

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

expect(tileKey).to.be.eql('124:12:42:256');
expect(tileKey).to.be.eql('124:12:42:256x256');
});
});
});
2 changes: 1 addition & 1 deletion src/DGPoi/src/DGPoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DG.Poi = DG.Handler.extend({

_processData : function (data, coord) {
var map = this._map,
tileOriginPoint = coord.multiplyBy(this._metaLayer._getTileSize());
tileOriginPoint = coord.scaleBy(this._metaLayer.getTileSize());

if (data.responseText === '') {
return [];
Expand Down
6 changes: 3 additions & 3 deletions src/DGProjectDetector/test/ProjectDetectorInSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,21 @@ describe('DG.ProjectDetectorIn', function () {
map.setView(project1, maxZoom);

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/DGProjectDetector/test/ProjectDetectorOutOfWorldSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,21 @@ describe('DG.ProjectDetectorOut', function () {
map.setView(project1, maxZoom);

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/DGProjectDetector/test/ProjectDetectorUnderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,21 @@ describe('DG.ProjectDetectorUnder', function () {
map.setView(project1, maxZoom);

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});

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

expect(map.fitWorld()).to.be(map);
expect(map.getZoom()).to.be(0);
expect(map.getZoom()).to.be(1);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/DGRuler/skin/basic/less/dg-ruler.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: absolute;
top: 0;
left: 0;
z-index: 4;
z-index: 400;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
.dg-ruler__label-spacer {
Expand Down
2 changes: 1 addition & 1 deletion src/DGTraffic/src/DGTraffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ DG.Traffic = DG.TileLayer.extend({

_processData: function (trafficData, coord) {
var map = this._map,
tileOriginPoint = coord.multiplyBy(this._getTileSize()),
tileOriginPoint = coord.scaleBy(this.getTileSize()),
hints = {};

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

0 comments on commit 3e340db

Please sign in to comment.