first commit
This commit is contained in:
BIN
libraries/ckeditor/plugins/leaflet/scripts/Leaflet-MiniMap/.DS_Store
vendored
Normal file
BIN
libraries/ckeditor/plugins/leaflet/scripts/Leaflet-MiniMap/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012, Norkart AS
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are
|
||||
permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
of conditions and the following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "leaflet-minimap",
|
||||
"version": "1.0.0",
|
||||
"author": "Norkart AS",
|
||||
"description": "A plugin for Leaflet that provides a minimap in the corner of the map view.",
|
||||
"license": "BSD-2-Clause",
|
||||
"readmeFilename": "README.md",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Norkart/Leaflet-MiniMap.git"
|
||||
},
|
||||
"homepage": "https://github.com/Norkart/Leaflet-MiniMap",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Norkart/Leaflet-MiniMap/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"leaflet": ">=0.5.0"
|
||||
},
|
||||
"keywords": [
|
||||
"maps",
|
||||
"leaflet",
|
||||
"client",
|
||||
"minimap"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
# Leaflet.MiniMap
|
||||
|
||||
Leaflet.MiniMap is a simple minimap control that you can drop into your leaflet map, and it will create a small map in the corner which shows the same as the main map with a set zoom offset. (By default it is -5.)
|
||||
|
||||
## Using the MiniMap control
|
||||
|
||||
The control can be inserted in two lines: First you have to construct a layer for it to use, and then you create and attach the minimap control. Don't reuse the layer you added to the main map, strange behaviour will ensue! Alternatively, you can pass in a LayerGroup with multiple layers (for example with overlays or suitably themed markers). Marker layers can't be reused either. (See issue #52 for a discussion of syncronising marker layers.)
|
||||
|
||||
From the [example](http://norkart.github.com/Leaflet-MiniMap/example.html):
|
||||
|
||||
var osm2 = new L.TileLayer(osmUrl, {minZoom: 0, maxZoom: 13, attribution: osmAttrib});
|
||||
var miniMap = new L.Control.MiniMap(osm2).addTo(map);
|
||||
|
||||
As the minimap control inherits from leaflet's control, positioning is handled automatically by leaflet. However, you can still style the minimap and set its size by modifying the css file.
|
||||
|
||||
**Note:** Leaflet version 0.5 or higher is required.
|
||||
|
||||
## Available Options
|
||||
The mini map uses options which can be set in the same way as other leaflet options, and these are the available options:
|
||||
|
||||
`position:` The standard Leaflet.Control position parameter, used like all the other controls. Defaults to 'bottomright'.
|
||||
|
||||
`width:` The width of the minimap in pixels. Defaults to 150.
|
||||
|
||||
`height:` The height of the minimap in pixels. Defaults to 150.
|
||||
|
||||
`zoomLevelOffset:` The offset applied to the zoom in the minimap compared to the zoom of the main map. Can be positive or negative, defaults to -5.
|
||||
|
||||
`zoomLevelFixed:` Overrides the offset to apply a fixed zoom level to the minimap regardless of the main map zoom. Set it to any valid zoom level, if unset `zoomLevelOffset` is used instead.
|
||||
|
||||
`zoomAnimation:` Sets whether the minimap should have an animated zoom. (Will cause it to lag a bit after the movement of the main map.) Defaults to false.
|
||||
|
||||
`toggleDisplay:` Sets whether the minimap should have a button to minimise it. Defaults to false.
|
||||
|
||||
`autoToggleDisplay:` Sets whether the minimap should hide automatically if the parent map bounds does not fit within the minimap bounds. Especially useful when 'zoomLevelFixed' is set.
|
||||
|
||||
`aimingRectOptions:` Sets the style of the aiming rectangle by passing in a [Path.Options object](http://leafletjs.com/reference.html#path-options). (Clickable will always be overridden and set to false.)
|
||||
|
||||
`shadowRectOptions:` Sets the style of the aiming shadow rectangle by passing in a [Path.Options object](http://leafletjs.com/reference.html#path-options). (Clickable will always be overridden and set to false.)
|
||||
|
||||
###Translation strings
|
||||
|
||||
These are not passed as options, but are overridden in a subclass. To do general translation overrides take a look at the german example sourcefile.
|
||||
|
||||
`hideText:` Text-String to be displayed as Tooltip when hovering over the toggle button on the MiniMap and it is visible.
|
||||
|
||||
`showText:` Text-String to be displayed as Tooltip when hovering over the toggle button on the MiniMap and it is hidden.
|
||||
BIN
libraries/ckeditor/plugins/leaflet/scripts/Leaflet-MiniMap/src/.DS_Store
vendored
Normal file
BIN
libraries/ckeditor/plugins/leaflet/scripts/Leaflet-MiniMap/src/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,43 @@
|
||||
.leaflet-control-minimap {
|
||||
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;
|
||||
transition: all .2s;
|
||||
}
|
||||
|
||||
.leaflet-control-minimap a {
|
||||
background-color: rgba(255, 255, 255, 1.0);
|
||||
background-repeat: no-repeat;
|
||||
z-index: 99999;
|
||||
transition: all .2s;
|
||||
border-radius: 3px 0px 0px 0px;
|
||||
}
|
||||
|
||||
.leaflet-control-minimap a.minimized {
|
||||
-webkit-transform: rotate(180deg);
|
||||
transform: rotate(180deg);
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
.leaflet-control-minimap-toggle-display {
|
||||
background-image: url("images/toggle.png");
|
||||
height: 19px;
|
||||
width: 19px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
/* Old IE */
|
||||
.leaflet-oldie .leaflet-control-minimap {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-minimap a {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-minimap a.minimized {
|
||||
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
L.Control.MiniMap = L.Control.extend({
|
||||
options: {
|
||||
position: 'bottomright',
|
||||
toggleDisplay: false,
|
||||
zoomLevelOffset: -5,
|
||||
zoomLevelFixed: false,
|
||||
zoomAnimation: false,
|
||||
autoToggleDisplay: false,
|
||||
width: 150,
|
||||
height: 150,
|
||||
aimingRectOptions: {color: "#ff7800", weight: 1, clickable: false},
|
||||
shadowRectOptions: {color: "#000000", weight: 1, clickable: false, opacity:0, fillOpacity:0}
|
||||
},
|
||||
|
||||
hideText: 'Hide MiniMap',
|
||||
|
||||
showText: 'Show MiniMap',
|
||||
|
||||
//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;
|
||||
},
|
||||
|
||||
onAdd: function (map) {
|
||||
|
||||
this._mainMap = map;
|
||||
|
||||
//Creating the container and stopping events from spilling through to the main map.
|
||||
this._container = L.DomUtil.create('div', 'leaflet-control-minimap');
|
||||
this._container.style.width = this.options.width + 'px';
|
||||
this._container.style.height = this.options.height + 'px';
|
||||
L.DomEvent.disableClickPropagation(this._container);
|
||||
L.DomEvent.on(this._container, 'mousewheel', L.DomEvent.stopPropagation);
|
||||
|
||||
|
||||
this._miniMap = new L.Map(this._container,
|
||||
{
|
||||
attributionControl: false,
|
||||
zoomControl: false,
|
||||
zoomAnimation: this.options.zoomAnimation,
|
||||
autoToggleDisplay: this.options.autoToggleDisplay,
|
||||
touchZoom: !this.options.zoomLevelFixed,
|
||||
scrollWheelZoom: !this.options.zoomLevelFixed,
|
||||
doubleClickZoom: !this.options.zoomLevelFixed,
|
||||
boxZoom: !this.options.zoomLevelFixed,
|
||||
crs: map.options.crs
|
||||
});
|
||||
|
||||
this._miniMap.addLayer(this._layer);
|
||||
|
||||
//These bools are used to prevent infinite loops of the two maps notifying each other that they've moved.
|
||||
this._mainMapMoving = false;
|
||||
this._miniMapMoving = false;
|
||||
|
||||
//Keep a record of this to prevent auto toggling when the user explicitly doesn't want it.
|
||||
this._userToggledDisplay = false;
|
||||
this._minimized = false;
|
||||
|
||||
if (this.options.toggleDisplay) {
|
||||
this._addToggleButton();
|
||||
}
|
||||
|
||||
this._miniMap.whenReady(L.Util.bind(function () {
|
||||
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);
|
||||
this._miniMap.on('move', this._onMiniMapMoving, this);
|
||||
this._miniMap.on('moveend', this._onMiniMapMoved, this);
|
||||
}, this));
|
||||
|
||||
return this._container;
|
||||
},
|
||||
|
||||
addTo: function (map) {
|
||||
L.Control.prototype.addTo.call(this, map);
|
||||
this._miniMap.setView(this._mainMap.getCenter(), this._decideZoom(true));
|
||||
this._setDisplay(this._decideMinimized());
|
||||
return this;
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
this._mainMap.off('moveend', this._onMainMapMoved, this);
|
||||
this._mainMap.off('move', this._onMainMapMoving, this);
|
||||
this._miniMap.off('moveend', this._onMiniMapMoved, this);
|
||||
|
||||
this._miniMap.removeLayer(this._layer);
|
||||
},
|
||||
|
||||
_addToggleButton: function () {
|
||||
this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton(
|
||||
'', this.hideText, 'leaflet-control-minimap-toggle-display', this._container, this._toggleDisplayButtonClicked, this) : undefined;
|
||||
},
|
||||
|
||||
_createButton: function (html, title, className, container, fn, context) {
|
||||
var link = L.DomUtil.create('a', className, container);
|
||||
link.innerHTML = html;
|
||||
link.href = '#';
|
||||
link.title = title;
|
||||
|
||||
var stop = L.DomEvent.stopPropagation;
|
||||
|
||||
L.DomEvent
|
||||
.on(link, 'click', stop)
|
||||
.on(link, 'mousedown', stop)
|
||||
.on(link, 'dblclick', stop)
|
||||
.on(link, 'click', L.DomEvent.preventDefault)
|
||||
.on(link, 'click', fn, context);
|
||||
|
||||
return link;
|
||||
},
|
||||
|
||||
_toggleDisplayButtonClicked: function () {
|
||||
this._userToggledDisplay = true;
|
||||
if (!this._minimized) {
|
||||
this._minimize();
|
||||
this._toggleDisplayButton.title = this.showText;
|
||||
}
|
||||
else {
|
||||
this._restore();
|
||||
this._toggleDisplayButton.title = this.hideText;
|
||||
}
|
||||
},
|
||||
|
||||
_setDisplay: function (minimize) {
|
||||
if (minimize != this._minimized) {
|
||||
if (!this._minimized) {
|
||||
this._minimize();
|
||||
}
|
||||
else {
|
||||
this._restore();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_minimize: function () {
|
||||
// hide the minimap
|
||||
if (this.options.toggleDisplay) {
|
||||
this._container.style.width = '19px';
|
||||
this._container.style.height = '19px';
|
||||
this._toggleDisplayButton.className += ' minimized';
|
||||
}
|
||||
else {
|
||||
this._container.style.display = 'none';
|
||||
}
|
||||
this._minimized = true;
|
||||
},
|
||||
|
||||
_restore: function () {
|
||||
if (this.options.toggleDisplay) {
|
||||
this._container.style.width = this.options.width + 'px';
|
||||
this._container.style.height = this.options.height + 'px';
|
||||
this._toggleDisplayButton.className = this._toggleDisplayButton.className
|
||||
.replace(/(?:^|\s)minimized(?!\S)/g, '');
|
||||
}
|
||||
else {
|
||||
this._container.style.display = 'block';
|
||||
}
|
||||
this._minimized = false;
|
||||
},
|
||||
|
||||
_onMainMapMoved: function (e) {
|
||||
if (!this._miniMapMoving) {
|
||||
this._mainMapMoving = true;
|
||||
this._miniMap.setView(this._mainMap.getCenter(), this._decideZoom(true));
|
||||
this._setDisplay(this._decideMinimized());
|
||||
} else {
|
||||
this._miniMapMoving = false;
|
||||
}
|
||||
this._aimingRect.setBounds(this._mainMap.getBounds());
|
||||
},
|
||||
|
||||
_onMainMapMoving: function (e) {
|
||||
this._aimingRect.setBounds(this._mainMap.getBounds());
|
||||
},
|
||||
|
||||
_onMiniMapMoveStarted:function (e) {
|
||||
var lastAimingRect = this._aimingRect.getBounds();
|
||||
var sw = this._miniMap.latLngToContainerPoint(lastAimingRect.getSouthWest());
|
||||
var ne = this._miniMap.latLngToContainerPoint(lastAimingRect.getNorthEast());
|
||||
this._lastAimingRectPosition = {sw:sw,ne:ne};
|
||||
},
|
||||
|
||||
_onMiniMapMoving: function (e) {
|
||||
if (!this._mainMapMoving && this._lastAimingRectPosition) {
|
||||
this._shadowRect.setBounds(new L.LatLngBounds(this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.sw),this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.ne)));
|
||||
this._shadowRect.setStyle({opacity:1,fillOpacity:0.3});
|
||||
}
|
||||
},
|
||||
|
||||
_onMiniMapMoved: function (e) {
|
||||
if (!this._mainMapMoving) {
|
||||
this._miniMapMoving = true;
|
||||
this._mainMap.setView(this._miniMap.getCenter(), this._decideZoom(false));
|
||||
this._shadowRect.setStyle({opacity:0,fillOpacity:0});
|
||||
} else {
|
||||
this._mainMapMoving = false;
|
||||
}
|
||||
},
|
||||
|
||||
_decideZoom: function (fromMaintoMini) {
|
||||
if (!this.options.zoomLevelFixed) {
|
||||
if (fromMaintoMini)
|
||||
return this._mainMap.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;
|
||||
else
|
||||
return this._mainMap.getZoom();
|
||||
}
|
||||
},
|
||||
|
||||
_decideMinimized: function () {
|
||||
if (this._userToggledDisplay) {
|
||||
return this._minimized;
|
||||
}
|
||||
|
||||
if (this.options.autoToggleDisplay) {
|
||||
if (this._mainMap.getBounds().contains(this._miniMap.getBounds())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return this._minimized;
|
||||
}
|
||||
});
|
||||
|
||||
L.Map.mergeOptions({
|
||||
miniMapControl: false
|
||||
});
|
||||
|
||||
L.Map.addInitHook(function () {
|
||||
if (this.options.miniMapControl) {
|
||||
this.miniMapControl = (new L.Control.MiniMap()).addTo(this);
|
||||
}
|
||||
});
|
||||
|
||||
L.control.minimap = function (options) {
|
||||
return new L.Control.MiniMap(options);
|
||||
};
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 345 B |
Reference in New Issue
Block a user