-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from oliverroick/leaflet-1.0.0
Leaflet 1.0.0
- Loading branch information
Showing
11 changed files
with
102 additions
and
42 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 |
---|---|---|
|
@@ -12,6 +12,12 @@ Substitutes polygons and lines with markers when their screen size falls below a | |
Usage | ||
===== | ||
|
||
Include `L.Deflate.js` from UNPKG: | ||
|
||
.. code-block:: html | ||
|
||
<script src="https://unpkg.com/[email protected]/dist/L.Deflate.js"></script> | ||
|
||
Initialize with the `minSize` option and add to map. `minSize` defines the minimum width and height in pixels for a path to be displayed in its actual shape. It defaults to `20`. | ||
|
||
.. code-block:: javascript | ||
|
@@ -55,13 +61,12 @@ Cluster Markers | |
|
||
With a little help from `Leaflet.Markercluster <https://github.com/Leaflet/Leaflet.markercluster>`_ and `Leaflet.Markercluster.LayerSupport <https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport>`_ you can cluster markers on your map. | ||
|
||
**Note:** You first have to check in your FeatureGroup with the MarkerClusterGroup and then add it to the map. | ||
|
||
.. code-block:: javascript | ||
var map = L.map("map"); | ||
var featureGroup = L.featureGroup(); | ||
featureGroup.addTo(map); | ||
L.Deflate({minSize: 10, featureGroup: featureGroup}).addTo(map); | ||
var polygon = L.polygon([ | ||
|
@@ -77,7 +82,10 @@ With a little help from `Leaflet.Markercluster <https://github.com/Leaflet/Leafl | |
var markerGroup = L.markerClusterGroup.layerSupport() | ||
markerGroup.addTo(map); | ||
markerGroup.checkIn(featureGroup); | ||
featureGroup.addTo(map); | ||
// Dirty hack; otherwise the cluster won't appear on the map. | ||
map.zoomIn(0); | ||
map.zoomOut(0); | ||
Developing | ||
========== | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,42 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<script src="../src/L.Deflate.js"></script> | ||
<style> | ||
#map { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
</style> | ||
</head> | ||
|
||
<div id="map"></div> | ||
|
||
<script> | ||
|
||
window.onload = function () { | ||
var map = L.map("map").setView([51.505, -0.09], 7); | ||
|
||
L.Deflate({minSize: 20}).addTo(map); | ||
|
||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
|
||
var polygon = L.polygon([ | ||
[51.509, -0.08], | ||
[51.503, -0.06], | ||
[51.51, -0.047] | ||
]); | ||
polygon.on('click', function() { | ||
alert('Yes, you clicked.') | ||
}); | ||
polygon.addTo(map); | ||
} | ||
</script> | ||
|
||
</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
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> | ||
<link rel="stylesheet" href="https://rawgit.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/MarkerCluster.css" /> | ||
<link rel="stylesheet" href="https://rawgit.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/MarkerCluster.Default.css" /> | ||
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> | ||
<script src="https://rawgit.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/leaflet.markercluster.js"></script> | ||
<script src="https://cdn.rawgit.com/ghybs/Leaflet.MarkerCluster.LayerSupport/3d4c4f24a008d6983a8f98b1c823f9a05ad62f80/leaflet.markercluster.layersupport-src.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | ||
<link rel="stylesheet" href="https://rawgit.com/Leaflet/Leaflet.markercluster/v1.0.0-rc.1/dist/MarkerCluster.css" /> | ||
<link rel="stylesheet" href="https://rawgit.com/Leaflet/Leaflet.markercluster/v1.0.0-rc.1/dist/MarkerCluster.Default.css" /> | ||
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> | ||
<script src="https://rawgit.com/Leaflet/Leaflet.markercluster/v1.0.0-rc.1/dist/leaflet.markercluster.js"></script> | ||
<script src="https://rawgit.com/ghybs/Leaflet.MarkerCluster.LayerSupport/v1.0.1/leaflet.markercluster.layersupport-src.js"></script> | ||
|
||
|
||
|
||
<script src="../src/L.Deflate.js"></script> | ||
<style> | ||
#map { | ||
|
@@ -23,17 +26,15 @@ | |
<script> | ||
|
||
window.onload = function () { | ||
var map = L.map("map").setView([51.505, -0.09], 7); | ||
var map = L.map("map").setView([51.505, -0.09], 12); | ||
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' | ||
}).addTo(map); | ||
|
||
var featureGroup = L.featureGroup(); | ||
|
||
featureGroup.addTo(map); | ||
L.Deflate({minSize: 20, featureGroup: featureGroup}).addTo(map); | ||
|
||
// Only this polygon is added the featureGroup, this is the only | ||
// feature affected by Leaflet.Deflate | ||
var polygon = L.polygon([ | ||
[51.509, -0.08], | ||
[51.503, -0.06], | ||
|
@@ -60,7 +61,11 @@ | |
var markerGroup = L.markerClusterGroup.layerSupport() | ||
markerGroup.addTo(map); | ||
markerGroup.checkIn(featureGroup); | ||
featureGroup.addTo(map); | ||
|
||
// Dirty hack; otherwise the cluster won't appear on the map. | ||
// Need to figure out what's going on. | ||
map.zoomIn(0); | ||
map.zoomOut(0); | ||
} | ||
</script> | ||
</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
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
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