Skip to content

Commit

Permalink
Merge 3155e8e into 5351cb4
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Dec 9, 2013
2 parents 5351cb4 + 3155e8e commit 8818903
Show file tree
Hide file tree
Showing 12 changed files with 1,020 additions and 577 deletions.
21 changes: 10 additions & 11 deletions leaflet/static/leaflet/Control.MiniMap.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
.leaflet-control-minimap {
border:solid rgba(255, 255, 255, 0.7) 3px;
box-shadow: 0 1px 7px #999;
border:solid rgba(255, 255, 255, 1.0) 4px;
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 3px;
background: #f8f8f9;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
transition: all .2s;
}

.leaflet-control-minimap a {
background-color: rgba(255, 255, 255, 0.75);
background-position: 1px 2px;
background-color: rgba(255, 255, 255, 1.0);
background-repeat: no-repeat;
display: block;
outline: none;
z-index: 99999;
transition: all .2s;
border-radius: 3px 0px 0px 0px;
}

.leaflet-control-minimap a.minimized {
background-position: 1px -18px;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
border-radius: 0px;
}

.leaflet-control-minimap-toggle-display {
background-image: url("images/toggle.png");
border-radius: 4px 4px 4px 4px;
height: 19px;
width: 19px;
position: absolute;
Expand Down
37 changes: 32 additions & 5 deletions leaflet/static/leaflet/Control.MiniMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ L.Control.MiniMap = L.Control.extend({
zoomAnimation: false,
autoToggleDisplay: false,
width: 150,
height: 150
height: 150,
aimingRectOptions: {color: "#ff7800", weight: 1, clickable: false},
shadowRectOptions: {color: "#000000", weight: 1, clickable: false, opacity:0, fillOpacity:0}
},

hideText: 'Hide MiniMap',
Expand All @@ -17,6 +19,9 @@ L.Control.MiniMap = L.Control.extend({
//layer is the map layer to be shown in the minimap
initialize: function (layer, options) {
L.Util.setOptions(this, options);
//Make sure the aiming rects are non-clickable even if the user tries to set them clickable (most likely by forgetting to specify them false)
this.options.aimingRectOptions.clickable = false;
this.options.shadowRectOptions.clickable = false;
this._layer = layer;
},

Expand Down Expand Up @@ -60,8 +65,8 @@ L.Control.MiniMap = L.Control.extend({
}

this._miniMap.whenReady(L.Util.bind(function () {
this._aimingRect = L.rectangle(this._mainMap.getBounds(), {color: "#ff7800", weight: 1, clickable: false}).addTo(this._miniMap);
this._shadowRect = L.rectangle(this._mainMap.getBounds(), {color: "#000000", weight: 1, clickable: false,opacity:0,fillOpacity:0}).addTo(this._miniMap);
this._aimingRect = L.rectangle(this._mainMap.getBounds(), this.options.aimingRectOptions).addTo(this._miniMap);
this._shadowRect = L.rectangle(this._mainMap.getBounds(), this.options.shadowRectOptions).addTo(this._miniMap);
this._mainMap.on('moveend', this._onMainMapMoved, this);
this._mainMap.on('move', this._onMainMapMoving, this);
this._miniMap.on('movestart', this._onMiniMapMoveStarted, this);
Expand Down Expand Up @@ -202,8 +207,30 @@ L.Control.MiniMap = L.Control.extend({
if (!this.options.zoomLevelFixed) {
if (fromMaintoMini)
return this._mainMap.getZoom() + this.options.zoomLevelOffset;
else
return this._miniMap.getZoom() - this.options.zoomLevelOffset;
else {
var currentDiff = this._miniMap.getZoom() - this._mainMap.getZoom();
var proposedZoom = this._miniMap.getZoom() - this.options.zoomLevelOffset;
var toRet;

if (currentDiff > this.options.zoomLevelOffset && this._mainMap.getZoom() < this._miniMap.getMinZoom() - this.options.zoomLevelOffset) {
//This means the miniMap is zoomed out to the minimum zoom level and can't zoom any more.
if (this._miniMap.getZoom() > this._lastMiniMapZoom) {
//This means the user is trying to zoom in by using the minimap, zoom the main map.
toRet = this._mainMap.getZoom() + 1;
//Also we cheat and zoom the minimap out again to keep it visually consistent.
this._miniMap.setZoom(this._miniMap.getZoom() -1);
} else {
//Either the user is trying to zoom out past the mini map's min zoom or has just panned using it, we can't tell the difference.
//Therefore, we ignore it!
toRet = this._mainMap.getZoom();
}
} else {
//This is what happens in the majority of cases, and always if you configure the min levels + offset in a sane fashion.
toRet = proposedZoom;
}
this._lastMiniMapZoom = this._miniMap.getZoom();
return toRet;
}
} else {
if (fromMaintoMini)
return this.options.zoomLevelFixed;
Expand Down
Binary file modified leaflet/static/leaflet/draw/images/spritesheet-2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified leaflet/static/leaflet/draw/images/spritesheet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8818903

Please sign in to comment.