forked from Norkart/Leaflet-MiniMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Events - `minimized`, `restore` and `toggle for both; add event example; update readme.
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>MiniMap Demo Events</title> | ||
<meta charset="utf-8" /> | ||
|
||
<link rel="stylesheet" href="./fullscreen.css" /> | ||
|
||
<!-- Leaflet --> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" type="text/javascript"></script> | ||
|
||
<!-- Leaflet Plugins --> | ||
<link rel="stylesheet" href="../src/Control.MiniMap.css" /> | ||
<script src="../src/Control.MiniMap.js" type="text/javascript"></script> | ||
|
||
</head> | ||
<body> | ||
<div id="map" ></div> | ||
|
||
<script type="text/javascript"> | ||
|
||
var map = new L.Map('map'); | ||
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; | ||
var osmAttrib='Map data © OpenStreetMap contributors'; | ||
var osm = new L.TileLayer(osmUrl, {minZoom: 5, maxZoom: 18, attribution: osmAttrib}); | ||
|
||
map.addLayer(osm); | ||
map.setView(new L.LatLng(59.92448055859924, 10.758276373601069),10); | ||
|
||
//Plugin magic goes here! Note that you cannot use the same layer object again, as that will confuse the two map controls | ||
var osm2 = new L.TileLayer(osmUrl, {minZoom: 0, maxZoom: 13, attribution: osmAttrib }); | ||
var miniMap = new L.Control.MiniMap(osm2, { toggleDisplay: true }).addTo(map); | ||
|
||
miniMap.on("toggle", function(data) { | ||
console.log("Listen for `toggle` event: miniMap is " + (data.minimized ? "minimized" : "restore")); | ||
}); | ||
miniMap.on("minimized", function() { | ||
console.log("Listen for `minimized` event"); | ||
}); | ||
miniMap.on("restore", function() { | ||
console.log("Listen for `restore` event"); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters