1

Trying to implement react-lealfet-draw with react-leaflet version 3.0.0. it throws an error /node_modules/react-leaflet-draw/dist/esm/EditControl.js Attempted import error: 'MapControl' is not exported from 'react-leaflet'.

import "./styles/leaflet.css";
import "leaflet/dist/leaflet.css";
import "leaflet-draw/dist/leaflet.draw.css";
import "leaflet-draw";
import L from "leaflet";
import "leaflet-splitmap";

import {MapConatiner, TileLayer} from 'react-leaflet';
import {EditControl} from 'react-leaflet-draw';

is there any way to implement leaflet-draw features with react-leaflet V3.0.0 ?

Emad Baqeri
  • 2,333
  • 2
  • 14
  • 29
  • react-leaflet-draw doesn't seem to be compatible with react-leaflet v3, hence the error. You'll need to rebuild it yourself as a react-leaflet v3 component or try to find a similar plugin that is already compatible with v3. – Seth Lutske Feb 24 '21 at 16:41
  • I down grade the react-leaflet to V2.0 and loose the feature of Side By Side tiles. Is there nay way to have splitMap in react-leaflet V2.0 – Emad Baqeri Feb 24 '21 at 18:43
  • Wellll how are you implementing leaflet-splitmap *now*? A quick search does not reveal any ready-made react-leaflet-splitmap components. Are you building it yourself? My general recommendation would be *not* to downgrade react-leaflet to v2, but rather make your own custom components for react-leaflet version 3, built on top of these existing vanilla leaflet plugins. I don't really have time to do this myself for you in an answer, but that would be the cleanest and more future-proof way to go about this – Seth Lutske Feb 25 '21 at 04:27
  • I think it was replaced with LayersControl. You can read more [here](https://react-leaflet.js.org/docs/example-layers-control/) – Semb Oct 20 '21 at 07:07
  • @Semb hey, thank you I have already done it with the leaflet on it's own, react-leaflet is not that flexible – Emad Baqeri Oct 20 '21 at 08:08

0 Answers0