Skip to content

Commit

Permalink
update leaflet version
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Svirid committed Jul 13, 2015
1 parent f34fd2b commit 5bda1f3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 40 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#f666890f1ad95fbf2b1eaef1a398fdf89d533e02",
"less": "^2.4.0",
"lodash": "^2.4.1",
"map-stream": "0.1.0",
Expand Down
43 changes: 23 additions & 20 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 @@ -167,30 +171,29 @@ 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; }

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

// prevents firing click after you just dragged an object
if (e.type === 'click' && !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);
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
data.latlng = this.layerPointToLatLng(data.layerPoint);
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 === 'click') {
target.fire('prepreclick', data, true);
target.fire('preclick', data, true);

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

this._fireDOMEvent(e, type);
}
});

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
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 5bda1f3

Please sign in to comment.