import React, { useState } from 'react'; import PropTypes from 'prop-types'; import ReactMapboxGl, { ZoomControl } from 'react-mapbox-gl'; import DrawControl from 'react-mapbox-gl-draw'; import { CursorClickIcon, PlusIcon, LocationMarkerIcon } from '@heroicons/react/outline'; import CoordinateInput from 'react-coordinate-input'; import { fire } from '@utils'; import VisuallyHidden from '@reach/visually-hidden'; import { useId } from '@reach/auto-id'; import 'mapbox-gl/dist/mapbox-gl.css'; import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'; import MapStyleControl, { useMapStyle } from '../shared/mapbox/MapStyleControl'; import { FlashMessage } from '../shared/FlashMessage'; import ComboAdresseSearch from '../ComboAdresseSearch'; import { useMapboxEditor } from './useMapboxEditor'; const Mapbox = ReactMapboxGl({}); function MapEditor({ featureCollection, url, options, preview }) { const [cadastreEnabled, setCadastreEnabled] = useState(false); const [coords, setCoords] = useState([1.7, 46.9]); const [zoom, setZoom] = useState([5]); const { isSupported, error, inputs, onLoad, onStyleChange, onFileChange, drawRef, createFeatures, updateFeatures, deleteFeatures, addInputFile, removeInputFile } = useMapboxEditor(featureCollection, { url, enabled: !preview, cadastreEnabled }); const { style, layers, setStyle, setLayerEnabled, setLayerOpacity } = useMapStyle(options.layers, { onStyleChange, cadastreEnabled }); if (!isSupported) { return (
Nous ne pouvons pas afficher notre éditeur de carte car il est imcompatible avec votre navigateur. Nous vous conseillons de le mettre à jour ou utiliser les dernières versions de Chrome, Firefox ou Safari
); } return ( <> {error &&Besoin d'aide ? consulter les tutoriels video