|
|
@@ -1,12 +1,12 @@
|
|
|
'use strict';
|
|
|
+import mapbox, { Map, Popup } from '../node_modules/mapbox-gl/dist/mapbox-gl.js';
|
|
|
+import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
|
+import FreeHand from 'mapbox-gl-draw-freehand-mode';
|
|
|
+import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
|
|
|
|
-mapboxgl.accessToken = 'pk.eyJ1IjoidGluYW1hIiwiYSI6ImNpbWV2dDJudjAxM2Z0c2traGthOTJyZjYifQ.s_lP9rp2Iro7Urb4IZAzTQ';
|
|
|
-const bounds = [
|
|
|
- [-2.460270, 53.370427],
|
|
|
- [-2.062598, 53.552900]
|
|
|
-]
|
|
|
+mapbox.accessToken = 'pk.eyJ1IjoidGluYW1hIiwiYSI6ImNpbWV2dDJudjAxM2Z0c2traGthOTJyZjYifQ.s_lP9rp2Iro7Urb4IZAzTQ';
|
|
|
|
|
|
-const map = new mapboxgl.Map({
|
|
|
+const map = new Map({
|
|
|
container: 'map',
|
|
|
style: 'mapbox://styles/tinama/ck7avipta06nj1jmomolvvrbr',
|
|
|
center: [-2.884808, 53.495743],
|
|
|
@@ -21,14 +21,12 @@ const Draw = new MapboxDraw({
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-console.log("turf", turf);
|
|
|
-
|
|
|
const AddPopup = (map) => (area) => {
|
|
|
let polygon = turf.polygon(area);
|
|
|
let center = turf.centroid(polygon);
|
|
|
console.log(center, polygon)
|
|
|
|
|
|
- return new mapboxgl.Popup({closeOnClick: false})
|
|
|
+ return new Popup({closeOnClick: false})
|
|
|
.setLngLat(center.geometry.coordinates)
|
|
|
.setHTML(`
|
|
|
<h3>form</h3>
|
|
|
@@ -39,7 +37,6 @@ const AddPopup = (map) => (area) => {
|
|
|
.addTo(map)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
map.addControl(Draw, 'top-right');
|
|
|
|
|
|
map.on('load', function() {
|