first commit

This commit is contained in:
2024-04-11 10:58:06 +02:00
commit 146bdb0b14
5691 changed files with 800415 additions and 0 deletions

Binary file not shown.

View File

@@ -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.

View File

@@ -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"
]
}

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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

View File

@@ -0,0 +1,75 @@
Leaflet-providers
=================
An extension to [Leaflet](http://leafletjs.com/) that contains configurations for various free tile providers.
# Usage
Leaflet-providers [providers](#providers) are refered to with a `provider[.<variant>]`-string. Let's say you want to add the nice [Watercolor](http://maps.stamen.com/#watercolor/) style from Stamen to your map, you pass `Stamen.Watercolor` to the `L.tileLayer.provider`-constructor, which will return a [L.TileLayer](http://leafletjs.com/reference.html#tilelayer) instance for Stamens Watercolor tile layer.
```Javascript
// add Stamen Watercolor to map.
L.tileLayer.provider('Stamen.Watercolor').addTo(map);
```
# Providers
Leaflet-providers provides tile layers from different providers, including *OpenStreetMap*, *MapQuestOpen*, *Stamen*, *Esri* and *OpenWeatherMap*. The full listing of free to use layers can be [previewed](http://leaflet-extras.github.io/leaflet-providers/preview/index.html). The page will show you the name to use with `leaflet-providers.js` and the code to use it without dependencies.
## Providers requiring registration
In addition to the providers you are free to use, we support some layers which require registration.
### Nokia.
In order to use Nokia basemaps, you must [register](https://developer.here.com/web/guest/myapps). With your `devID` and `appID` specified in the options, the available layers are:
* Nokia.normalDay
* Nokia.normalGreyDay
* Nokia.satelliteNoLabelsDay
* Nokia.satelliteYesLabelsDay
* Nokia.terrainDay
For example:
```Javascript
L.tileLayer.provider('Nokia.terrainDay', {
devID: 'insert ID here',
appId: 'insert ID here'
}).addTo(map);
```
### Mapbox
In order to use Mapbox maps, you must [register](https://tiles.mapbox.com/signup). If your user name is `YourName` and your map is called `MyMap` you can add it with
```JavaScript
L.tileLayer.provider('MapBox.YourName.MyMap');
```
### Esri/ArcGIS
In order to use ArcGIS maps, you must [register](https://developers.arcgis.com/en/sign-up/) and abide by the [terms of service](https://developers.arcgis.com/en/terms/). Available layers are...
* Esri.WorldStreetMap
* Esri.DeLorme
* Esri.WorldTopoMap
* Esri.WorldImagery
* Esri.WorldTerrain
* Esri.WorldShadedRelief
* Esri.WorldPhysical
* Esri.OceanBasemap
* Esri.NatGeoWorldMap
* Esri.WorldGrayCanvas
# Goodies
An other little goodie this library provides is a prefilled layer control, so you can just provide an array of strings:
```JavaScript
var baseLayers = ['Stamen.Watercolor', 'OpenStreetMap.Mapnik'],
overlays = ['OpenWeatherMap.Clouds'];
var layerControl = L.control.layers.provided(baseLayers, overlays).addTo(map);
// you can still add your own afterwards with
layerControl.addBaseLayer(layer, name);
```
This work was inspired from <https://gist.github.com/1804938>, and originally created by [Stefan Seelmann](https://github.com/seelmann).

View File

@@ -0,0 +1,153 @@
<!doctype html>
<html lang="en">
<head>
<title>Leaflet Provider Demo</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- Leaflet style. REQUIRED! -->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<style>
html { height: 100% }
body { height: 100%; margin: 0; padding: 0;}
.map { height: 100% }
</style>
<!--Fork Me on Github ribbon, we're using the awsome version from simonwhitaker available at https://github.com/simonwhitaker/github-fork-ribbon-css -->
<link rel="stylesheet" href="css/gh-fork-ribbon.css" />
<!--[if IE]>
<link rel="stylesheet" href="css/gh-fork-ribbon.ie.css" />
<![endif]-->
</head>
<body>
<div class="github-fork-ribbon-wrapper left">
<div class="github-fork-ribbon">
<a href="https://github.com/leaflet-extras/leaflet-providers">Fork me on GitHub</a>
</div>
</div>
<div id="map" class="map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet-src.js"></script>
<script src="leaflet-providers.js"></script>
<script>
var map = L.map('map', {
center: [48, -3],
zoom: 5,
zoomControl: false
});
var defaultLayer = L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map);
var baseLayers = {
'OpenStreetMap Default': defaultLayer,
'OpenStreetMap German Style': L.tileLayer.provider('OpenStreetMap.DE'),
'OpenStreetMap Black and White': L.tileLayer.provider('OpenStreetMap.BlackAndWhite'),
'OpenStreetMap H.O.T.': L.tileLayer.provider('OpenStreetMap.HOT'),
'Thunderforest OpenCycleMap': L.tileLayer.provider('Thunderforest.OpenCycleMap'),
'Thunderforest Transport': L.tileLayer.provider('Thunderforest.Transport'),
'Thunderforest Landscape': L.tileLayer.provider('Thunderforest.Landscape'),
'MapQuest OSM': L.tileLayer.provider('MapQuestOpen.OSM'),
'MapQuest Aerial': L.tileLayer.provider('MapQuestOpen.Aerial'),
'MapBox Example': L.tileLayer.provider('MapBox.examples.map-zr0njcqy'),
'Stamen Toner': L.tileLayer.provider('Stamen.Toner'),
'Stamen Terrain': L.tileLayer.provider('Stamen.Terrain'),
'Stamen Watercolor': L.tileLayer.provider('Stamen.Watercolor'),
'Esri WorldStreetMap': L.tileLayer.provider('Esri.WorldStreetMap'),
'Esri DeLorme': L.tileLayer.provider('Esri.DeLorme'),
'Esri WorldTopoMap': L.tileLayer.provider('Esri.WorldTopoMap'),
'Esri WorldImagery': L.tileLayer.provider('Esri.WorldImagery'),
'Esri WorldTerrain': L.tileLayer.provider('Esri.WorldTerrain'),
'Esri WorldShadedRelief': L.tileLayer.provider('Esri.WorldShadedRelief'),
'Esri WorldPhysical': L.tileLayer.provider('Esri.WorldPhysical'),
'Esri OceanBasemap': L.tileLayer.provider('Esri.OceanBasemap'),
'Esri NatGeoWorldMap': L.tileLayer.provider('Esri.NatGeoWorldMap'),
'Esri WorldGrayCanvas': L.tileLayer.provider('Esri.WorldGrayCanvas'),
'Nokia Normal Day': L.tileLayer.provider('Nokia.normalDay'),
'Nokia Normal Day Grey': L.tileLayer.provider('Nokia.normalGreyDay'),
'Nokia Satellite': L.tileLayer.provider('Nokia.satelliteNoLabelsDay'),
'Nokia Satellite (Labeled)': L.tileLayer.provider('Nokia.satelliteYesLabelsDay'),
'Nokia Terrain': L.tileLayer.provider('Nokia.terrainDay'),
'Acetate': L.tileLayer.provider('Acetate')
};
var overlayLayers = {
'OpenSeaMap': L.tileLayer.provider('OpenSeaMap'),
'OpenWeatherMap Clouds': L.tileLayer.provider('OpenWeatherMap.Clouds'),
'OpenWeatherMap CloudsClassic': L.tileLayer.provider('OpenWeatherMap.CloudsClassic'),
'OpenWeatherMap Precipitation': L.tileLayer.provider('OpenWeatherMap.Precipitation'),
'OpenWeatherMap PrecipitationClassic': L.tileLayer.provider('OpenWeatherMap.PrecipitationClassic'),
'OpenWeatherMap Rain': L.tileLayer.provider('OpenWeatherMap.Rain'),
'OpenWeatherMap RainClassic': L.tileLayer.provider('OpenWeatherMap.RainClassic'),
'OpenWeatherMap Pressure': L.tileLayer.provider('OpenWeatherMap.Pressure'),
'OpenWeatherMap PressureContour': L.tileLayer.provider('OpenWeatherMap.PressureContour'),
'OpenWeatherMap Wind': L.tileLayer.provider('OpenWeatherMap.Wind'),
'OpenWeatherMap Temperature': L.tileLayer.provider('OpenWeatherMap.Temperature'),
'OpenWeatherMap Snow': L.tileLayer.provider('OpenWeatherMap.Snow')
};
var layerControl = L.control.layers(baseLayers, overlayLayers, {collapsed: false}).addTo(map);
/* you could also use the following code instead
var map = new L.Map('map').setView([48, -3],5);
var defaultLayer = L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map);
var baseLayers = [
'OpenStreetMap.Mapnik',
'OpenStreetMap.DE',
'OpenStreetMap.BlackAndWhite',
'Thunderforest.OpenCycleMap',
'Thunderforest.Transport',
'Thunderforest.Landscape',
'MapQuestOpen.OSM',
'MapQuestOpen.Aerial',
'MapBox.examples.map-zr0njcqy',
'Stamen.Toner',
'Stamen.Terrain',
'Stamen.Watercolor',
'Esri.WorldStreetMap',
'Esri.DeLorme',
'Esri.WorldTopoMap',
'Esri.WorldImagery',
'Esri.WorldTerrain',
'Esri.WorldShadedRelief',
'Esri.WorldPhysical',
'Esri.OceanBasemap',
'Esri.NatGeoWorldMap',
'Esri.WorldGrayCanvas',
'Nokia.normalDay',
'Nokia.normalGreyDay',
'Nokia.satelliteNoLabelsDay',
'Nokia.satelliteYesLabelsDay,
'Nokia.terrainDay'
];
var overlayLayers = [
'OpenWeatherMap.Clouds',
'OpenWeatherMap.CloudsClassic',
'OpenWeatherMap.Precipitation',
'OpenWeatherMap.PrecipitationClassic',
'OpenWeatherMap.Rain',
'OpenWeatherMap.RainClassic',
'OpenWeatherMap.Pressure',
'OpenWeatherMap.PressureContour',
'OpenWeatherMap.Wind',
'OpenWeatherMap.Temperature',
'OpenWeatherMap.Snow'
];
L.control.layers.provided(baseLayers, overlayLayers, {collapsed: false}).addTo(map);
*/
// resize layers control to fit into view.
function resizeLayerControl() {
var layerControlHeight = document.body.clientHeight - (10 + 50);
var layerControl = document.getElementsByClassName('leaflet-control-layers-expanded')[0];
layerControl.style.overflowY = 'auto';
layerControl.style.maxHeight = layerControlHeight + 'px';
}
map.on('resize', resizeLayerControl);
resizeLayerControl();
</script>
</body>
</html>

View File

@@ -0,0 +1,458 @@
(function () {
'use strict';
L.TileLayer.Provider = L.TileLayer.extend({
initialize: function (arg, options) {
var providers = L.TileLayer.Provider.providers;
var parts = arg.split('.');
var providerName = parts[0];
var variantName = parts[1];
if (!providers[providerName]) {
throw 'No such provider (' + providerName + ')';
}
var provider = {
url: providers[providerName].url,
options: providers[providerName].options
};
// overwrite values in provider from variant.
if (variantName && 'variants' in providers[providerName]) {
if (!(variantName in providers[providerName].variants)) {
throw 'No such name in provider (' + variantName + ')';
}
var variant = providers[providerName].variants[variantName];
provider = {
url: variant.url || provider.url,
options: L.Util.extend({}, provider.options, variant.options)
};
} else if (typeof provider.url === 'function') {
provider.url = provider.url(parts.splice(1, parts.length - 1).join('.'));
}
// replace attribution placeholders with their values from toplevel provider attribution,
// recursively
var attributionReplacer = function (attr) {
if (attr.indexOf('{attribution.') === -1) {
return attr;
}
return attr.replace(/\{attribution.(\w*)\}/,
function (match, attributionName) {
return attributionReplacer(providers[attributionName].options.attribution);
}
);
};
provider.options.attribution = attributionReplacer(provider.options.attribution);
// Compute final options combining provider options with any user overrides
var layerOpts = L.Util.extend({}, provider.options, options);
L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts);
}
});
/**
* Definition of providers.
* see http://leafletjs.com/reference.html#tilelayer for options in the options map.
*/
//jshint maxlen:220
L.TileLayer.Provider.providers = {
OpenStreetMap: {
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {
attribution:
'&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
},
variants: {
Mapnik: {},
BlackAndWhite: {
url: 'http://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png'
},
DE: {
url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png'
},
HOT: {
url: 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
}
}
}
},
OpenCycleMap: {
url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
options: {
attribution:
'&copy; <a href="http://www.opencyclemap.org">OpenCycleMap</a>, {attribution.OpenStreetMap}'
}
},
OpenSeaMap: {
url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
options: {
attribution: 'Map data: &copy; <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
}
},
Thunderforest: {
url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenCycleMap}'
},
variants: {
OpenCycleMap: {},
Transport: {
url: 'http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png'
},
Landscape: {
url: 'http://{s}.tile3.opencyclemap.org/landscape/{z}/{x}/{y}.png'
},
Outdoors: {
url: 'http://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png'
}
}
},
OpenMapSurfer: {
url: 'http://openmapsurfer.uni-hd.de/tiles/roads/x={x}&y={y}&z={z}',
options: {
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> &mdash; Map data {attribution.OpenStreetMap}'
},
variants: {
Roads: {},
AdminBounds: {
url: 'http://openmapsurfer.uni-hd.de/tiles/adminb/x={x}&y={y}&z={z}'
},
Grayscale: {
url: 'http://openmapsurfer.uni-hd.de/tiles/roadsg/x={x}&y={y}&z={z}'
}
}
},
MapQuestOpen: {
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
options: {
attribution:
'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
'Map data {attribution.OpenStreetMap}',
subdomains: '1234'
},
variants: {
OSM: {},
Aerial: {
url: 'http://oatile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',
options: {
attribution:
'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency'
}
}
}
},
MapBox: {
url: function (id) {
return 'http://{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png';
},
options: {
attribution:
'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> &mdash; ' +
'Map data {attribution.OpenStreetMap}',
subdomains: 'abcd'
}
},
Stamen: {
url: 'http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.png',
options: {
attribution:
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; ' +
'Map data {attribution.OpenStreetMap}',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20
},
variants: {
Toner: {},
TonerBackground: {
url: 'http://{s}.tile.stamen.com/toner-background/{z}/{x}/{y}.png'
},
TonerHybrid: {
url: 'http://{s}.tile.stamen.com/toner-hybrid/{z}/{x}/{y}.png'
},
TonerLines: {
url: 'http://{s}.tile.stamen.com/toner-lines/{z}/{x}/{y}.png'
},
TonerLabels: {
url: 'http://{s}.tile.stamen.com/toner-labels/{z}/{x}/{y}.png'
},
TonerLite: {
url: 'http://{s}.tile.stamen.com/toner-lite/{z}/{x}/{y}.png'
},
Terrain: {
url: 'http://{s}.tile.stamen.com/terrain/{z}/{x}/{y}.jpg',
options: {
minZoom: 4,
maxZoom: 18
}
},
TerrainBackground: {
url: 'http://{s}.tile.stamen.com/terrain-background/{z}/{x}/{y}.jpg',
options: {
minZoom: 4,
maxZoom: 18
}
},
Watercolor: {
url: 'http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg',
options: {
minZoom: 3,
maxZoom: 16
}
}
}
},
Esri: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
options: {
attribution: 'Tiles &copy; Esri'
},
variants: {
WorldStreetMap: {
options: {
attribution:
'{attribution.Esri} &mdash; ' +
'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
}
},
DeLorme: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer/tile/{z}/{y}/{x}',
options: {
minZoom: 1,
maxZoom: 11,
attribution: '{attribution.Esri} &mdash; Copyright: &copy;2012 DeLorme'
}
},
WorldTopoMap: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
options: {
attribution:
'{attribution.Esri} &mdash; ' +
'Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community'
}
},
WorldImagery: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
options: {
attribution:
'{attribution.Esri} &mdash; ' +
'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
}
},
WorldTerrain: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 13,
attribution:
'{attribution.Esri} &mdash; ' +
'Source: USGS, Esri, TANA, DeLorme, and NPS'
}
},
WorldShadedRelief: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 13,
attribution: '{attribution.Esri} &mdash; Source: Esri'
}
},
WorldPhysical: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 8,
attribution: '{attribution.Esri} &mdash; Source: US National Park Service'
}
},
OceanBasemap: {
url: 'http://services.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 13,
attribution: '{attribution.Esri} &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
}
},
NatGeoWorldMap: {
url: 'http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 16,
attribution: '{attribution.Esri} &mdash; National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
}
},
WorldGrayCanvas: {
url: 'http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',
options: {
maxZoom: 16,
attribution: '{attribution.Esri} &mdash; Esri, DeLorme, NAVTEQ'
}
}
}
},
OpenWeatherMap: {
options: {
attribution: 'Map data &copy; <a href="http://openweathermap.org">OpenWeatherMap</a>',
opacity: 0.5
},
variants: {
Clouds: {
url: 'http://{s}.tile.openweathermap.org/map/clouds/{z}/{x}/{y}.png'
},
CloudsClassic: {
url: 'http://{s}.tile.openweathermap.org/map/clouds_cls/{z}/{x}/{y}.png'
},
Precipitation: {
url: 'http://{s}.tile.openweathermap.org/map/precipitation/{z}/{x}/{y}.png'
},
PrecipitationClassic: {
url: 'http://{s}.tile.openweathermap.org/map/precipitation_cls/{z}/{x}/{y}.png'
},
Rain: {
url: 'http://{s}.tile.openweathermap.org/map/rain/{z}/{x}/{y}.png'
},
RainClassic: {
url: 'http://{s}.tile.openweathermap.org/map/rain_cls/{z}/{x}/{y}.png'
},
Pressure: {
url: 'http://{s}.tile.openweathermap.org/map/pressure/{z}/{x}/{y}.png'
},
PressureContour: {
url: 'http://{s}.tile.openweathermap.org/map/pressure_cntr/{z}/{x}/{y}.png'
},
Wind: {
url: 'http://{s}.tile.openweathermap.org/map/wind/{z}/{x}/{y}.png'
},
Temperature: {
url: 'http://{s}.tile.openweathermap.org/map/temp/{z}/{x}/{y}.png'
},
Snow: {
url: 'http://{s}.tile.openweathermap.org/map/snow/{z}/{x}/{y}.png'
}
}
},
Nokia: {
options: {
attribution:
'Map &copy; <a href="http://developer.here.com">Nokia</a>, Data &copy; NAVTEQ 2012',
subdomains: '1234',
devID: 'xyz', //These basemaps are free and you can sign up here: http://developer.here.com/plans
appID: 'abc'
},
variants: {
normalDay: {
url: 'http://{s}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/normal.day/{z}/{x}/{y}/256/png8?token={devID}&app_id={appID}'
},
normalGreyDay: {
url: 'http://{s}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/normal.day.grey/{z}/{x}/{y}/256/png8?token={devID}&app_id={appID}'
},
satelliteNoLabelsDay: {
url: 'http://{s}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/satellite.day/{z}/{x}/{y}/256/png8?token={devID}&app_id={appID}'
},
satelliteYesLabelsDay: {
url: 'http://{s}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/hybrid.day/{z}/{x}/{y}/256/png8?token={devID}&app_id={appID}'
},
terrainDay: {
url: 'http://{s}.maptile.lbs.ovi.com/maptiler/v2/maptile/newest/terrain.day/{z}/{x}/{y}/256/png8?token={devID}&app_id={appID}'
}
}
},
Acetate: {
url: 'http://a{s}.acetate.geoiq.com/tiles/acetate-hillshading/{z}/{x}/{y}.png',
options: {
attribution:
'&copy;2012 Esri & Stamen, Data from OSM and Natural Earth',
subdomains: '0123',
minZoom: 2,
maxZoom: 18
},
variants: {
all: {},
basemap: {
url: 'http://a{s}.acetate.geoiq.com/tiles/acetate-base/{z}/{x}/{y}.png'
},
terrain: {
url: 'http://a{s}.acetate.geoiq.com/tiles/terrain/{z}/{x}/{y}.png'
},
foreground: {
url: 'http://a{s}.acetate.geoiq.com/tiles/acetate-fg/{z}/{x}/{y}.png'
},
roads: {
url: 'http://a{s}.acetate.geoiq.com/tiles/acetate-roads/{z}/{x}/{y}.png'
},
labels: {
url: 'http://a{s}.acetate.geoiq.com/tiles/acetate-labels/{z}/{x}/{y}.png'
},
hillshading: {
url: 'http://a{s}.acetate.geoiq.com/tiles/hillshading/{z}/{x}/{y}.png'
}
}
}
};
L.tileLayer.provider = function (provider, options) {
return new L.TileLayer.Provider(provider, options);
};
L.Control.Layers.Provided = L.Control.Layers.extend({
initialize: function (base, overlay, options) {
var first;
var labelFormatter = function (label) {
return label.replace(/\./g, ': ').replace(/([a-z])([A-Z])/g, '$1 $2');
};
if (base.length) {
(function () {
var out = {},
len = base.length,
i = 0;
while (i < len) {
if (typeof base[i] === 'string') {
if (i === 0) {
first = L.tileLayer.provider(base[0]);
out[labelFormatter(base[i])] = first;
} else {
out[labelFormatter(base[i])] = L.tileLayer.provider(base[i]);
}
}
i++;
}
base = out;
}());
this._first = first;
}
if (overlay && overlay.length) {
(function () {
var out = {},
len = overlay.length,
i = 0;
while (i < len) {
if (typeof overlay[i] === 'string') {
out[labelFormatter(overlay[i])] = L.tileLayer.provider(overlay[i]);
}
i++;
}
overlay = out;
}());
}
L.Control.Layers.prototype.initialize.call(this, base, overlay, options);
},
onAdd: function (map) {
this._first.addTo(map);
return L.Control.Layers.prototype.onAdd.call(this, map);
}
});
L.control.layers.provided = function (baseLayers, overlays, options) {
return new L.Control.Layers.Provided(baseLayers, overlays, options);
};
}());

View File

@@ -0,0 +1,9 @@
Copyright (c) 2013 Leaflet Providers contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* 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._

View File

@@ -0,0 +1,20 @@
{
"name": "leaflet-providers",
"version": "1.0.3",
"description": "An extension to Leaflet that contains configurations for various free tile providers.",
"main": "leaflet-providers.js",
"repository": {
"type": "git",
"url": "git://github.com/leaflet-extras/leaflet-providers.git"
},
"scripts":{
"pretest":"jshint leaflet-providers.js"
},
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/leaflet-extras/leaflet-providers/issues"
},
"devDependencies": {
"jshint": "~2.1.11"
}
}

View File

@@ -0,0 +1,180 @@
<!DOCTYPE html>
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css" />
<script src="leaflet-providers/leaflet-providers.js"></script>
<script src="Leaflet-MiniMap/src/Control.MiniMap.js"></script>
<link rel="stylesheet" href="Leaflet-MiniMap/src/Control.MiniMap.css" />
<script type="text/javascript" charset="utf-8">
// Function to parse the URL search query parameters.
// It will give A, B, C given http://www.somelink.com?lat=A&lon=B&zoom=C
// See "http://javascriptproductivity.blogspot.com/" +
// "2013/02/get-url-variables-with-javascript.html".
function getParams(){
// Make an object variable to hold
// the parsed URL parameters' keys and vlaues.
var params = {};
// Remove the '?' character after the base url.
// x.substring(i) will return the substring of x starting at index i
// up to the end of the string.
// Drupal CMS might have a path like this (two '?' characters):
// mapParser.html?t=E3OD?lat=14.6760413&lon=121.0437003&...
// We need to handle this case also.
var lastIndex = window.location.search.lastIndexOf("?")
// Get the substring not including any '?' character.
var query_string = window.location.search.substring(lastIndex + 1);
// Explode the string using the '&' character.
var query_string_parts = query_string.split('&');
// Traverse the exploded tokens.
for(i in query_string_parts) {
// Explode the string using '=' to isolate keys and values.
key_value = query_string_parts[i].split('=');
// Insert a new key and set it to the current parsed value.
params[key_value[0]] = key_value[1];
}
// Return the parameter object contianing the keys and values.
return params;
}
</script>
<style>
.leaflet-popup-content {
text-align: center;
}
body {
padding: 0;
margin: 0;
}
html, body, #map_container {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id='map_container' data-lat="" data-lon="" data-zoom=""></div>
<script type="text/javascript">
// Get the DOM node to which we will append the map.
// In our setup the map container is a DIV element.
var mapDiv = document.getElementById("map_container");
// Parse the query parameters in the URL to obtain the
// LAT, LON, and ZOOM values.
var queryString = getParams();
// Fetch the most important attributes.
var latitude = queryString["lat"];
var longitude= queryString["lon"];
var zoom = queryString["zoom"];
// Initialize the mapDiv data attributes.
mapDiv.setAttribute("data-lat", latitude);
mapDiv.setAttribute("data-lon", longitude);
mapDiv.setAttribute("data-zoom", zoom);
// Convert the parameters to their numeric equivalent.
// Otherwise, initializing the Leaflet map object will not work.
latitude = Number(latitude);
longitude = Number(longitude);
zoom = Number(zoom);
var responsive = queryString["responsive"];
// If responsive map option is enabled, set the map height to 100%.
if (responsive == "on") {
mapDiv.style.height = "100%";
}
else {
// Retrieve the map's height.
var mapHeight = Number(queryString["height"]);
mapDiv.style.height = String(mapHeight) + "px";
}
// Retrive the popup text that will be used by the marker.
var popUpText = decodeURIComponent(queryString["text"]);
// Retrieve the Base Map's Tile to be used.
var tile = queryString["tile"];
// Retrieve the information about the inclusion of Overview map.
var minimap = queryString["minimap"];
// Create a map in the the target DOM container.
// Set the view to a given place and zoom value.
var map = L.map('map_container').setView([latitude, longitude], zoom);
// Choose the Map Tile provider e.g. "Esri.WorldTopoMap"
var mapTileProvider = tile;
var restrictedTiles = ['MapQuestOpen.Aerial', 'MapQuestOpen.OSM'];
// Redirect MapQuest tiles to OpenStreetMap tiles.
if (restrictedTiles.indexOf(mapTileProvider) != -1) {
mapTileProvider = 'OpenStreetMap.Mapnik';
}
// Set the base map.
var mapTile = L.tileLayer.provider(mapTileProvider, { attribution: "Map Tile: " + mapTileProvider });
mapTile.addTo(map);
// Add a marker in the given location.
// Make it draggble so that user could refine the position visually.
var p1 = L.marker([latitude, longitude], {
draggable: true,
});
p1.addTo(map);
// Add an event listener that will keep track the changes in the
// marker location and will update the data attribute accordingly.
p1.on('dragend', function(e) {
var newLocation = this.getLatLng();
var lat = newLocation.lat;
var lon = newLocation.lng;
// Pan the map to its new center which is the last position
// of the dragged marker.
map.panTo([lat, lon]);
mapDiv.setAttribute("data-lat", String(lat));
mapDiv.setAttribute("data-lon", String(lon));
});
// If the pop-up text is specified.
if (popUpText != '') {
// Replace the %20 HTML Entity by an empty space.
// %20 is the result of texts being piped via URL.
popUpText = popUpText.replace(/%20/g, ' ');
// Bind the text to the current marker.
p1.bindPopup(popUpText);
}
// Check if MiniMap needs to be shown also.
if (minimap == "on") {
// Create a new Tile Layer for the MiniMap.
// Per documentation, do not reuse the existing Tile object
// to avoid rendering issues.
var mapTile2 = L.tileLayer.provider(mapTileProvider);
var miniMap = new L.Control.MiniMap(mapTile2).addTo(map);
}
// Add an event listener that will keep track the changes in the
// map's zoom levels and it will update the data attribute accordingly.
map.on('zoomend', function(e) {
mapDiv.setAttribute("data-zoom", map.getZoom());
});
</script>
</body>
</html>