Skip to content

Commit

Permalink
docs: add greedyCollapse example
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverroick committed Aug 14, 2021
1 parent 2f8b779 commit 7a30bea
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions example/greedy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<html>
<head>
<!-- <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet-src.js"></script> -->
<meta charset="utf-8">
<script src='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.3.1/mapbox.css' rel='stylesheet' />
<script src="../src/L.Deflate.js"></script>
<style>
#map {
position: absolute;
top: 15px;
left: 15px;
bottom: 15px;
right: 15px;
}
</style>
</head>

<div id="map"></div>

<script>

window.onload = function () {
L.mapbox.accessToken = 'pk.eyJ1Ijoib2xpdmVycm9pY2siLCJhIjoiY2phYTEyenM1MG02bTJxcTh0dHpmam1mNyJ9.wgmvIsRRvVSkj8_8z9yhUQ';

var map = L.map("map").setView([
51.50556382164291,
-0.09128093719482422,
], 12);

var baselayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});
baselayer.addTo(map);

var features = L.deflate({minSize: 20, greedyCollapse: false});
features.addTo(map);

L.polygon([
[51.503, -0.09],
[51.509, -0.09],
[51.509, -0.15],
[51.503, -0.15],
]).addTo(features);

var features2 = L.deflate({minSize: 20, greedyCollapse: true});
features2.addTo(map);

L.polygon([
[51.510, -0.06],
[51.516, -0.06],
[51.516, -0.12],
[51.510, -0.12],
]).addTo(features2);
}
</script>

</html>

0 comments on commit 7a30bea

Please sign in to comment.