-
-
Notifications
You must be signed in to change notification settings - Fork 774
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of maplibre-gl-draw (#5086)
* Add example of maplibre-gl-draw * changelog * use latest v2 * use latest * use latest turf * fixes * don't revert title
- Loading branch information
Showing
3 changed files
with
19 additions
and
18 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
File renamed without changes
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,8 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Show drawn polygon area</title> | ||
<meta property="og:description" content="Use mapbox-gl-draw to draw a polygon and Turf.js to calculate its area in square meters." /> | ||
<title>Draw polygon with maplibre-gl-draw</title> | ||
<meta property="og:description" content="Use jsr:@birkskyum/maplibre-gl-draw to draw a polygon and Turf.js to calculate its area in square meters." /> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel='stylesheet' href='../../dist/maplibre-gl.css' /> | ||
|
@@ -31,23 +31,25 @@ | |
font-size: 13px; | ||
} | ||
</style> | ||
|
||
<script src="https://www.unpkg.com/[email protected]/turf.min.js"></script> | ||
<script src="https://www.unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-draw.js"></script> | ||
<link | ||
rel="stylesheet" | ||
href="https://www.unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-draw.css" | ||
/> | ||
<div id="map"></div> | ||
<div class="calculation-box"> | ||
<p>Draw a polygon using the draw tools.</p> | ||
<div id="calculated-area"></div> | ||
</div> | ||
href="https://esm.sh/jsr/@birkskyum/maplibre-gl-draw@^2/dist/maplibre-gl-draw.css" | ||
/> | ||
<div id="map"></div> | ||
<div class="calculation-box"> | ||
<p>Draw a polygon using the draw tools.</p> | ||
<div id="calculated-area"></div> | ||
</div> | ||
|
||
<script type="module"> | ||
|
||
|
||
import * as turf from 'https://esm.sh/@turf/[email protected]'; | ||
|
||
<script> | ||
MapboxDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl'; | ||
MapboxDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-'; | ||
MapboxDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group'; | ||
import {MapLibreDraw} from 'https://esm.sh/jsr/@birkskyum/maplibre-gl-draw@^2'; | ||
MapLibreDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl'; | ||
MapLibreDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-'; | ||
MapLibreDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group'; | ||
|
||
const map = new maplibregl.Map({ | ||
container: 'map', // container id | ||
|
@@ -57,7 +59,7 @@ | |
zoom: 12 // starting zoom | ||
}); | ||
|
||
const draw = new MapboxDraw({ | ||
const draw = new MapLibreDraw({ | ||
displayControlsDefault: false, | ||
controls: { | ||
polygon: true, | ||
|