react-leaflet-deflate 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +4 -4
- package/dist/react-leaflet-deflate.min.js.LICENSE.txt +9 -9
- package/docs/App.jsx +299 -0
- package/docs/_config.yml +1 -0
- package/docs/css/business-frontpage.css +8 -0
- package/docs/geojsonSamples.js +149 -0
- package/docs/index.html +132 -0
- package/docs/vendor/bootstrap/css/bootstrap.css +9887 -0
- package/docs/vendor/bootstrap/css/bootstrap.css.map +1 -0
- package/docs/vendor/bootstrap/css/bootstrap.min.css +7 -0
- package/docs/vendor/bootstrap/css/bootstrap.min.css.map +1 -0
- package/docs/vendor/bootstrap/js/bootstrap.bundle.js +6818 -0
- package/docs/vendor/bootstrap/js/bootstrap.bundle.js.map +1 -0
- package/docs/vendor/bootstrap/js/bootstrap.bundle.min.js +7 -0
- package/docs/vendor/bootstrap/js/bootstrap.bundle.min.js.map +1 -0
- package/docs/vendor/bootstrap/js/bootstrap.js +4249 -0
- package/docs/vendor/bootstrap/js/bootstrap.js.map +1 -0
- package/docs/vendor/bootstrap/js/bootstrap.min.js +7 -0
- package/docs/vendor/bootstrap/js/bootstrap.min.js.map +1 -0
- package/docs/vendor/jquery/jquery.js +10364 -0
- package/docs/vendor/jquery/jquery.min.js +2 -0
- package/docs/vendor/jquery/jquery.min.map +1 -0
- package/docs/vendor/jquery/jquery.slim.js +8269 -0
- package/docs/vendor/jquery/jquery.slim.min.js +2 -0
- package/docs/vendor/jquery/jquery.slim.min.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
react-leaflet-deflate Changelog
|
|
2
2
|
=========================
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
## 3.1.0 (2025-12-05)
|
|
6
|
+
|
|
7
|
+
* Add gh-pages docs
|
|
8
|
+
* Update dependencies
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## 3.0.1 (2025-11-28)
|
|
12
|
+
|
|
13
|
+
* NPM Audit Fix
|
|
14
|
+
|
|
4
15
|
## 3.0.0 (2025-11-07)
|
|
5
16
|
|
|
6
17
|
* Update Leaflet.Deflate dependency to 2.1.0.
|
package/README.md
CHANGED
|
@@ -72,12 +72,12 @@ Option | Type | Default | Description
|
|
|
72
72
|
`data` | `object` | `{}` | Required. A valid [GeoJSON object](http://geojson.org/geojson-spec.html).
|
|
73
73
|
`minSize` | `int` | `20` | Defines the minimum width and height in pixels for a path to be displayed in its actual shape.
|
|
74
74
|
`markerOptions` | `object` or `function` | `{}` | Optional. Customize the markers of deflated features using [Leaflet marker options](http://leafletjs.com/reference-1.3.0.html#marker).
|
|
75
|
-
`markerCluster` | `boolean` | `false` | Indicates whether markers should be clustered. Requires `Leaflet.
|
|
75
|
+
`markerCluster` | `boolean` | `false` | Indicates whether markers should be clustered. Requires `Leaflet.markercluster`.
|
|
76
76
|
`markerClusterOptions` | `object` | `{}` | Optional. Customize the appearance and behaviour of clustered markers using [`Leaflet.markercluster` options](https://github.com/Leaflet/Leaflet.markercluster#options).
|
|
77
77
|
`pointToLayer` | `function` | `{}` | [Leaflet geojson pointToLayer options](http://leafletjs.com/reference-1.3.0.html#geojson-pointtolayer).
|
|
78
|
-
`style` | `function` | `{}` | Style to apply to polygons or lines. [Leaflet geojson style options](
|
|
79
|
-
`onEachFeature` | `function` | `{}` | Function to execute on each geojson feature. [Leaflet geojson onEachFeature options](
|
|
80
|
-
`filter` | `function` | `{}` | Filter function to apply to geojson features. [Leaflet geojson filter options](
|
|
78
|
+
`style` | `function` | `{}` | Style to apply to polygons or lines. [Leaflet geojson style options](https://leafletjs.com/reference.html#geojson-style).
|
|
79
|
+
`onEachFeature` | `function` | `{}` | Function to execute on each geojson feature. [Leaflet geojson onEachFeature options](https://leafletjs.com/reference.html#geojson-oneachfeature).
|
|
80
|
+
`filter` | `function` | `{}` | Filter function to apply to geojson features. [Leaflet geojson filter options](https://leafletjs.com/reference.html#geojson-filter).
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
# Credits
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-dom.production.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-dom.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
package/docs/App.jsx
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOMClient from 'react-dom/client';
|
|
4
|
+
import { MapContainer, TileLayer } from 'react-leaflet';
|
|
5
|
+
import Deflate from 'react-leaflet-deflate';
|
|
6
|
+
|
|
7
|
+
function App() {
|
|
8
|
+
const [mapOptions] = React.useState({
|
|
9
|
+
center: [2.935403, 101.448205],
|
|
10
|
+
zoom: 10,
|
|
11
|
+
minZoom: 1,
|
|
12
|
+
maxZoom: 22
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const [markerCluster, setMarkerCluster] = React.useState(true);
|
|
16
|
+
const [dataSet, setDataSet] = React.useState(1);
|
|
17
|
+
const [minSize, setMinSize] = React.useState(null);
|
|
18
|
+
|
|
19
|
+
const onChangeMarkerCluster = (e) => setMarkerCluster(e.target.checked);
|
|
20
|
+
const onChangeDataSet = (e) => setDataSet(e.target.value);
|
|
21
|
+
|
|
22
|
+
const onChangeMinSize = (e) => {
|
|
23
|
+
const minSizeInput = e.target.value;
|
|
24
|
+
let minSizeFloat = parseFloat(minSizeInput);
|
|
25
|
+
if(isNaN(minSizeFloat) || minSizeFloat <= 1.0) {
|
|
26
|
+
minSizeFloat = null;
|
|
27
|
+
}
|
|
28
|
+
setMinSize(minSizeFloat);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const onEachFeature = (feature, featureLayer) => {
|
|
32
|
+
featureLayer.bindPopup(`<div>This is feature #${feature.properties.id}</div>`);
|
|
33
|
+
featureLayer.bindTooltip(`Feature: #${feature.properties.id}`);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const resetOptions = () => {
|
|
37
|
+
setMarkerCluster(true);
|
|
38
|
+
setDataSet(1);
|
|
39
|
+
setMinSize(null);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const deflateOptions = {
|
|
43
|
+
minSize: minSize || 20,
|
|
44
|
+
markerCluster: markerCluster,
|
|
45
|
+
data: dataSet == 1 ? sample1 : sample2,
|
|
46
|
+
onEachFeature: onEachFeature
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div>
|
|
51
|
+
<div className="row d-flex">
|
|
52
|
+
<div className="col-md-8 align-self-stretch">
|
|
53
|
+
<div className="card" style={{ height: '500px' }}>
|
|
54
|
+
<div className="card-body">
|
|
55
|
+
<MapContainer {...mapOptions} className="h-100">
|
|
56
|
+
<TileLayer
|
|
57
|
+
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
58
|
+
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
|
|
59
|
+
/>
|
|
60
|
+
<Deflate {...deflateOptions} />
|
|
61
|
+
</MapContainer>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<div className="col-md-4">
|
|
66
|
+
<div className="card" style={{ height: '500px' }} >
|
|
67
|
+
<div className="card-body">
|
|
68
|
+
<div className="row">
|
|
69
|
+
<div className="col-sm-6">
|
|
70
|
+
<h6 className="mt-1"><i className="fas fa-cogs" /> Options</h6>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="col-sm-6 text-right">
|
|
73
|
+
<button type="button" className="btn btn-sm btn-outline-info" onClick={resetOptions}>
|
|
74
|
+
<i className="fas fa-undo-alt" /> Reset
|
|
75
|
+
</button>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<hr/>
|
|
79
|
+
<form>
|
|
80
|
+
<div className="form-group row">
|
|
81
|
+
<label htmlFor="cluster" className="col-sm-6 col-form-label">Enable marker clustering:</label>
|
|
82
|
+
<div className="col-sm-6">
|
|
83
|
+
<input
|
|
84
|
+
className="form-control"
|
|
85
|
+
id="cluster"
|
|
86
|
+
name="cluster"
|
|
87
|
+
type="checkbox"
|
|
88
|
+
checked={markerCluster}
|
|
89
|
+
onChange={onChangeMarkerCluster}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
<div className="form-group row">
|
|
94
|
+
<label htmlFor="minSize" className="col-sm-6 col-form-label">Min. Size:</label>
|
|
95
|
+
<div className="col-sm-6">
|
|
96
|
+
<input
|
|
97
|
+
className="form-control"
|
|
98
|
+
id="minSize"
|
|
99
|
+
name="minSize"
|
|
100
|
+
type="number"
|
|
101
|
+
value={minSize}
|
|
102
|
+
onChange={onChangeMinSize}
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<div className="form-group row">
|
|
107
|
+
<label htmlFor="geojson" className="col-sm-6 col-form-label">GeoJSON data set:</label>
|
|
108
|
+
<div className="col-sm-6">
|
|
109
|
+
<select className="form-control" id="geojson" name="geojson" value={dataSet} onChange={onChangeDataSet}>
|
|
110
|
+
<option value="1">Data set 1</option>
|
|
111
|
+
<option value="2">Data set 2</option>
|
|
112
|
+
</select>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</form>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="row">
|
|
121
|
+
<div className="col-md-12 mt-4">
|
|
122
|
+
<div className="card">
|
|
123
|
+
<div className="card-body">
|
|
124
|
+
<h4>Installation</h4>
|
|
125
|
+
<hr />
|
|
126
|
+
<h5>Install via NPM</h5>
|
|
127
|
+
<div className="card bg-dark text-white">
|
|
128
|
+
<div className="card-body">
|
|
129
|
+
<code className="text-white">
|
|
130
|
+
npm install react-leaflet-deflate --save
|
|
131
|
+
</code>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
<div className="row">
|
|
139
|
+
<div className="col-md-12 mt-4">
|
|
140
|
+
<div className="card">
|
|
141
|
+
<div className="card-body">
|
|
142
|
+
<h4>Usage</h4>
|
|
143
|
+
<hr />
|
|
144
|
+
|
|
145
|
+
<h5>Example</h5>
|
|
146
|
+
<div className="card bg-dark text-white">
|
|
147
|
+
<div className="card-body">
|
|
148
|
+
<pre><code className="text-white">
|
|
149
|
+
import { MapContainer, TileLayer } from 'react-leaflet';<br />
|
|
150
|
+
import Deflate from 'react-leaflet-deflate';<br />
|
|
151
|
+
<br />
|
|
152
|
+
const deflateOptions = {<br />
|
|
153
|
+
minSize: 20,<br />
|
|
154
|
+
markerCluster: true,<br />
|
|
155
|
+
data: geojsonData<br />
|
|
156
|
+
};<br />
|
|
157
|
+
<br />
|
|
158
|
+
<MapContainer center={[101.483459, 2.938926]} zoom={12}><br />
|
|
159
|
+
<TileLayer<br />
|
|
160
|
+
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"<br/>
|
|
161
|
+
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
162
|
+
/>
|
|
163
|
+
<br />
|
|
164
|
+
<br />
|
|
165
|
+
|
|
166
|
+
<Deflate {...deflateOptions} /><br />
|
|
167
|
+
</MapContainer>
|
|
168
|
+
</code></pre>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<h5 className="mt-4">react-leaflet v5</h5>
|
|
173
|
+
<iframe
|
|
174
|
+
style={{ height: '420px', width: '100%' }}
|
|
175
|
+
scrolling="no"
|
|
176
|
+
title="react-leaflet-deflate example for react-leaflet@5.x"
|
|
177
|
+
src="https://codepen.io/m_hasbie/embed/wBGampr/?height=265&theme-id=0&default-tab=html,result"
|
|
178
|
+
frameBorder="no"
|
|
179
|
+
allowTransparency="true"
|
|
180
|
+
allowFullScreen="true"
|
|
181
|
+
>
|
|
182
|
+
See the Pen <a href='https://codepen.io/m_hasbie/pen/wBGampr/'>react-leaflet-deflate example for react-leaflet@5.x</a> by M. Hasbie
|
|
183
|
+
(<a href='https://codepen.io/m_hasbie'>@m_hasbie</a>) on <a href='https://codepen.io'>CodePen</a>.
|
|
184
|
+
</iframe>
|
|
185
|
+
|
|
186
|
+
<h5 className="mt-4">react-leaflet v2</h5>
|
|
187
|
+
<iframe
|
|
188
|
+
style={{ height: '420px', width: '100%' }}
|
|
189
|
+
scrolling="no"
|
|
190
|
+
title="react-leaflet-deflate example for react-leaflet@2.x"
|
|
191
|
+
src="https://codepen.io/m_hasbie/embed/MqNPRy/?height=265&theme-id=0&default-tab=js,result"
|
|
192
|
+
frameBorder="no"
|
|
193
|
+
allowTransparency="true"
|
|
194
|
+
allowFullScreen="true"
|
|
195
|
+
>
|
|
196
|
+
See the Pen <a href='https://codepen.io/m_hasbie/pen/MqNPRy/'>react-leaflet-deflate example for react-leaflet@2.x</a> by M. Hasbie
|
|
197
|
+
(<a href='https://codepen.io/m_hasbie'>@m_hasbie</a>) on <a href='https://codepen.io'>CodePen</a>.
|
|
198
|
+
</iframe>
|
|
199
|
+
|
|
200
|
+
<h5 className="mt-4">react-leaflet v1</h5>
|
|
201
|
+
<iframe
|
|
202
|
+
style={{ height: '420px', width: '100%' }}
|
|
203
|
+
scrolling="no"
|
|
204
|
+
title="react-leaflet-deflate example for react-leaflet@1.9.1"
|
|
205
|
+
src="http://codepen.io/m_hasbie/embed/jvgeVR/?height=265&theme-id=0&default-tab=js,result"
|
|
206
|
+
frameBorder="no"
|
|
207
|
+
allowTransparency="true"
|
|
208
|
+
allowFullScreen="true"
|
|
209
|
+
>
|
|
210
|
+
See the Pen <a href='https://codepen.io/m_hasbie/pen/jvgeVR/'>react-leaflet-deflate example for react-leaflet@1.9.1</a> by M. Hasbie
|
|
211
|
+
(<a href='https://codepen.io/m_hasbie'>@m_hasbie</a>) on <a href='https://codepen.io'>CodePen</a>.
|
|
212
|
+
</iframe>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
<div className="row">
|
|
218
|
+
<div className="col-md-12 mt-4">
|
|
219
|
+
<div className="card">
|
|
220
|
+
<div className="card-body">
|
|
221
|
+
<h4>Options</h4>
|
|
222
|
+
<hr />
|
|
223
|
+
|
|
224
|
+
<table className="table table-hover table-striped table-bordered">
|
|
225
|
+
<thead className="thead-dark">
|
|
226
|
+
<tr>
|
|
227
|
+
<th>Option</th>
|
|
228
|
+
<th>Type</th>
|
|
229
|
+
<th>Default</th>
|
|
230
|
+
<th>Description</th>
|
|
231
|
+
</tr>
|
|
232
|
+
</thead>
|
|
233
|
+
<tbody>
|
|
234
|
+
<tr>
|
|
235
|
+
<td className="text-nowrap"><code>data</code></td>
|
|
236
|
+
<td><code>data</code></td>
|
|
237
|
+
<td><code>{}</code></td>
|
|
238
|
+
<td>Required. A valid <a href="http://geojson.org/geojson-spec.html" rel="nofollow">GeoJSON object</a>.</td>
|
|
239
|
+
</tr>
|
|
240
|
+
<tr>
|
|
241
|
+
<td className="text-nowrap"><code>minSize</code></td>
|
|
242
|
+
<td><code>int</code></td>
|
|
243
|
+
<td><code>20</code></td>
|
|
244
|
+
<td>Defines the minimum width and height in pixels for a path to be displayed in its actual shape.</td>
|
|
245
|
+
</tr>
|
|
246
|
+
<tr>
|
|
247
|
+
<td className="text-nowrap"><code>markerOptions</code></td>
|
|
248
|
+
<td><code>object</code> or <code>function</code></td>
|
|
249
|
+
<td><code>{}</code></td>
|
|
250
|
+
<td>Optional. Customize the markers of deflated features using <a href="http://leafletjs.com/reference-1.3.0.html#marker" rel="nofollow">Leaflet marker options</a>.</td>
|
|
251
|
+
</tr>
|
|
252
|
+
<tr>
|
|
253
|
+
<td className="text-nowrap"><code>markerCluster</code></td>
|
|
254
|
+
<td><code>boolean</code></td>
|
|
255
|
+
<td><code>false</code></td>
|
|
256
|
+
<td>Indicates whether markers should be clustered. Requires <code>Leaflet.markercluster</code>.</td>
|
|
257
|
+
</tr>
|
|
258
|
+
<tr>
|
|
259
|
+
<td className="text-nowrap"><code>markerClusterOptions</code></td>
|
|
260
|
+
<td><code>object</code></td>
|
|
261
|
+
<td><code>{}</code></td>
|
|
262
|
+
<td>Optional. Customize the appearance and behaviour of clustered markers using <a href="https://github.com/Leaflet/Leaflet.markercluster#options"><code>Leaflet.markercluster</code> options</a>.</td>
|
|
263
|
+
</tr>
|
|
264
|
+
<tr>
|
|
265
|
+
<td className="text-nowrap"><code>pointToLayer</code></td>
|
|
266
|
+
<td><code>function</code></td>
|
|
267
|
+
<td><code>{}</code></td>
|
|
268
|
+
<td><a href="https://leafletjs.com/reference.html#geojson-pointtolayer" rel="nofollow">Leaflet geojson pointToLayer options</a>.</td>
|
|
269
|
+
</tr>
|
|
270
|
+
<tr>
|
|
271
|
+
<td className="text-nowrap"><code>style</code></td>
|
|
272
|
+
<td><code>function</code></td>
|
|
273
|
+
<td><code>{}</code></td>
|
|
274
|
+
<td>Style to apply to polygons or lines. <a href="https://leafletjs.com/reference.html#geojson-style" rel="nofollow">Leaflet geojson style options</a>.</td>
|
|
275
|
+
</tr>
|
|
276
|
+
<tr>
|
|
277
|
+
<td className="text-nowrap"><code>onEachFeature</code></td>
|
|
278
|
+
<td><code>function</code></td>
|
|
279
|
+
<td><code>{}</code></td>
|
|
280
|
+
<td>Function to execute on each geojson feature. <a href="https://leafletjs.com/reference.html#geojson-oneachfeature" rel="nofollow">Leaflet geojson onEachFeature options</a>.</td>
|
|
281
|
+
</tr>
|
|
282
|
+
<tr>
|
|
283
|
+
<td className="text-nowrap"><code>filter</code></td>
|
|
284
|
+
<td><code>function</code></td>
|
|
285
|
+
<td><code>{}</code></td>
|
|
286
|
+
<td>Filter function to apply to geojson features. <a href="https://leafletjs.com/reference.html#geojson-filter" rel="nofollow">Leaflet geojson filter options</a>.</td>
|
|
287
|
+
</tr>
|
|
288
|
+
</tbody>
|
|
289
|
+
</table>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const root = ReactDOMClient.createRoot(document.getElementById('container'));
|
|
299
|
+
root.render(<App />);
|
package/docs/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-slate
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Start Bootstrap - Busines Frontpage (https://startbootstrap.com/template-overviews/business-frontpage)
|
|
3
|
+
* Copyright 2013-2019 Start Bootstrap
|
|
4
|
+
* Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-business-frontpage/blob/master/LICENSE)
|
|
5
|
+
*/
|
|
6
|
+
body {
|
|
7
|
+
padding-top: 56px;
|
|
8
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
|
|
2
|
+
var sample1 = {
|
|
3
|
+
"type": "FeatureCollection",
|
|
4
|
+
"features": [
|
|
5
|
+
{
|
|
6
|
+
"type": "Feature",
|
|
7
|
+
"properties": { id: 1 },
|
|
8
|
+
"geometry": {
|
|
9
|
+
"type": "Polygon",
|
|
10
|
+
"coordinates": [[
|
|
11
|
+
[101.448205, 2.935403],
|
|
12
|
+
[101.452839, 2.935961],
|
|
13
|
+
[101.450479, 2.932746],
|
|
14
|
+
[101.448205, 2.935403]
|
|
15
|
+
]]
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "Feature",
|
|
20
|
+
"properties": { id: 2 },
|
|
21
|
+
"geometry": {
|
|
22
|
+
"type": "Polygon",
|
|
23
|
+
"coordinates": [[
|
|
24
|
+
[101.427943, 2.951690],
|
|
25
|
+
[101.431891, 2.952804],
|
|
26
|
+
[101.428801, 2.948518],
|
|
27
|
+
[101.427943, 2.951690]
|
|
28
|
+
]]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "Feature",
|
|
33
|
+
"properties": { id: 3 },
|
|
34
|
+
"geometry": {
|
|
35
|
+
"type": "Polygon",
|
|
36
|
+
"coordinates": [[
|
|
37
|
+
[101.448765, 3.006379],
|
|
38
|
+
[101.476918, 2.993179],
|
|
39
|
+
[101.434346, 2.981693],
|
|
40
|
+
[101.448765, 3.006379]
|
|
41
|
+
]]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
var sample2 = {
|
|
48
|
+
"type": "FeatureCollection",
|
|
49
|
+
"features": [
|
|
50
|
+
{
|
|
51
|
+
"type": "Feature",
|
|
52
|
+
"properties": { id: 1 },
|
|
53
|
+
"geometry": {
|
|
54
|
+
"type": "Polygon",
|
|
55
|
+
"coordinates": [
|
|
56
|
+
[
|
|
57
|
+
[
|
|
58
|
+
101.43951416015625,
|
|
59
|
+
3.195363798329405
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
101.41342163085938,
|
|
63
|
+
3.1693115059053554
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
101.46217346191406,
|
|
67
|
+
3.160398728694278
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
101.50062561035156,
|
|
71
|
+
3.2063329870791444
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
101.43951416015625,
|
|
75
|
+
3.195363798329405
|
|
76
|
+
]
|
|
77
|
+
]
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "Feature",
|
|
83
|
+
"properties": { id: 2 },
|
|
84
|
+
"geometry": {
|
|
85
|
+
"type": "Polygon",
|
|
86
|
+
"coordinates": [
|
|
87
|
+
[
|
|
88
|
+
[
|
|
89
|
+
101.54525756835938,
|
|
90
|
+
3.14325855753886
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
101.55555725097656,
|
|
94
|
+
3.14325855753886
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
101.55555725097656,
|
|
98
|
+
3.153542694120099
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
101.54525756835938,
|
|
102
|
+
3.153542694120099
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
101.54525756835938,
|
|
106
|
+
3.14325855753886
|
|
107
|
+
]
|
|
108
|
+
]
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "Feature",
|
|
114
|
+
"properties": { id: 3},
|
|
115
|
+
"geometry": {
|
|
116
|
+
"type": "Point",
|
|
117
|
+
"coordinates": [
|
|
118
|
+
101.54525756835938,
|
|
119
|
+
2.9204112651768823
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "Feature",
|
|
125
|
+
"properties": { id: 4 },
|
|
126
|
+
"geometry": {
|
|
127
|
+
"type": "LineString",
|
|
128
|
+
"coordinates": [
|
|
129
|
+
[
|
|
130
|
+
101.55693054199219,
|
|
131
|
+
2.9608700037783326
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
101.63932800292969,
|
|
135
|
+
2.984184539248731
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
101.64207458496094,
|
|
139
|
+
2.9210970187084637
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
101.57546997070312,
|
|
143
|
+
2.938926463242253
|
|
144
|
+
]
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
6
|
+
<meta name="description" content="https://github.com/mhasbie/react-leaflet-deflate">
|
|
7
|
+
<meta name="author" content="M. Hasbie">
|
|
8
|
+
|
|
9
|
+
<title>react-leaflet-deflate Demo Page</title>
|
|
10
|
+
|
|
11
|
+
<script type="importmap">
|
|
12
|
+
{
|
|
13
|
+
"imports": {
|
|
14
|
+
"react": "https://esm.sh/react@19.2.3/",
|
|
15
|
+
"react-dom/client": "https://esm.sh/react-dom@19.2.3/client",
|
|
16
|
+
"react-leaflet": "https://esm.sh/react-leaflet@5.0.0/",
|
|
17
|
+
"@react-leaflet/core": "https://cdn.esm.sh/@react-leaflet/core",
|
|
18
|
+
"react-leaflet-deflate": "https://esm.sh/react-leaflet-deflate@3.0.1/",
|
|
19
|
+
"Leaflet.Deflate": "https://cdn.jsdelivr.net/npm/Leaflet.Deflate@2.1.0/dist/L.Deflate.min.js",
|
|
20
|
+
"leaflet.markercluster": "https://unpkg.com/leaflet.markercluster"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- Bootstrap core CSS -->
|
|
26
|
+
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
|
27
|
+
|
|
28
|
+
<!-- Custom styles for this template -->
|
|
29
|
+
<link href="css/business-frontpage.css" rel="stylesheet">
|
|
30
|
+
|
|
31
|
+
<!-- Font Awesome -->
|
|
32
|
+
<!--<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">-->
|
|
33
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
|
|
34
|
+
|
|
35
|
+
<!-- Dependencies css -->
|
|
36
|
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.css" rel="stylesheet">
|
|
37
|
+
<link href="https://cdn.jsdelivr.net/npm/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.min.css" rel="stylesheet">
|
|
38
|
+
<link href="https://cdn.jsdelivr.net/npm/leaflet.markercluster@1.5.3/dist/MarkerCluster.min.css" rel="stylesheet">
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
.leaflet-container {
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 100%!important;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<!-- Navigation -->
|
|
49
|
+
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
|
|
50
|
+
<div class="container">
|
|
51
|
+
<a class="navbar-brand" href="#">react-leaflet-deflate</a>
|
|
52
|
+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
|
|
53
|
+
<span class="navbar-toggler-icon"></span>
|
|
54
|
+
</button>
|
|
55
|
+
<div class="collapse navbar-collapse" id="navbarResponsive">
|
|
56
|
+
<ul class="navbar-nav ml-auto">
|
|
57
|
+
<li class="nav-item active">
|
|
58
|
+
<a class="nav-link" href="#">Home
|
|
59
|
+
<span class="sr-only">(current)</span>
|
|
60
|
+
</a>
|
|
61
|
+
</li>
|
|
62
|
+
<!--
|
|
63
|
+
<li class="nav-item">
|
|
64
|
+
<a class="nav-link" href="#">About</a>
|
|
65
|
+
</li>
|
|
66
|
+
<li class="nav-item">
|
|
67
|
+
<a class="nav-link" href="#">Services</a>
|
|
68
|
+
</li>
|
|
69
|
+
<li class="nav-item">
|
|
70
|
+
<a class="nav-link" href="#">Contact</a>
|
|
71
|
+
</li>
|
|
72
|
+
-->
|
|
73
|
+
</ul>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</nav>
|
|
77
|
+
|
|
78
|
+
<!-- Header -->
|
|
79
|
+
<header class="bg-dark mb-4">
|
|
80
|
+
<div class="container h-100">
|
|
81
|
+
<div class="row h-100 align-items-center">
|
|
82
|
+
<div class="col-lg-12">
|
|
83
|
+
<h1 class="display-4 text-white mb-2">react-leaflet-deflate</h1>
|
|
84
|
+
<p class="lead mb-4 text-white-50">
|
|
85
|
+
React wrapper of <a href="https://github.com/oliverroick/Leaflet.Deflate">Leaflet.Deflate</a> for <a href="https://github.com/PaulLeCam/react-leaflet">react-leaflet</a>.
|
|
86
|
+
<br/>
|
|
87
|
+
Substitutes polygons and lines with markers when their screen size falls below a defined threshold.
|
|
88
|
+
<div class="btn-group">
|
|
89
|
+
<a class="btn btn-outline-light" href="https://github.com/mhasbie/react-leaflet-deflate" title="View on Github">
|
|
90
|
+
<i class="fab fa-github"></i> Github
|
|
91
|
+
</a>
|
|
92
|
+
<a class="btn btn-outline-light" href="https://www.npmjs.com/package/react-leaflet-deflate" title="View on npm">
|
|
93
|
+
<i class="fab fa-npm"></i> npm
|
|
94
|
+
</a>
|
|
95
|
+
</div>
|
|
96
|
+
</p>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</header>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
<div class="container">
|
|
104
|
+
<div class="row">
|
|
105
|
+
<div class="col-md-12 mb-5">
|
|
106
|
+
<div id="container"></div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
<!-- /.container -->
|
|
111
|
+
|
|
112
|
+
<!-- Footer -->
|
|
113
|
+
<footer class="py-5 bg-dark">
|
|
114
|
+
<div class="container">
|
|
115
|
+
<p class="m-0 text-center text-white">© M. Hasbie 2025</p>
|
|
116
|
+
</div>
|
|
117
|
+
</footer>
|
|
118
|
+
|
|
119
|
+
<!-- Bootstrap core JavaScript -->
|
|
120
|
+
<script src="vendor/jquery/jquery.min.js"></script>
|
|
121
|
+
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
|
122
|
+
|
|
123
|
+
<!-- Dependencies JavaScript -->
|
|
124
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.28.4/babel.min.js"></script>
|
|
125
|
+
|
|
126
|
+
<!-- Sample Data -->
|
|
127
|
+
<script src="./geojsonSamples.js"></script>
|
|
128
|
+
|
|
129
|
+
<!-- Main App -->
|
|
130
|
+
<script type="text/babel" src="App.jsx" data-type="module" ></script>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|