Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't draw polygons/polylines using leaflet, leaflet.draw #1054

Open
kashkumar12 opened this issue Nov 21, 2022 · 1 comment
Open

Couldn't draw polygons/polylines using leaflet, leaflet.draw #1054

kashkumar12 opened this issue Nov 21, 2022 · 1 comment

Comments

@kashkumar12
Copy link

kashkumar12 commented Nov 21, 2022

I could easily draw rectangle, circle and markers as well, but I am not able to draw polygon or polyline. Here is my code,
`

import L from "leaflet";
import "leaflet/dist/leaflet.css";
import 'leaflet-draw/dist/leaflet.draw.css';
import 'leaflet-draw/dist/leaflet.draw-src.css';
import 'leaflet-draw'
useEffect(() => {
    var mapDisplay = L.map("map", {drawLayers:true, drawControl:true, drawControlTooltips:true}).setView(
      [-26.4391, 133.2813],
      5
    );
    let drawLayers = new L.FeatureGroup()
    mapDisplay .addLayer(drawLayers)

    var drawnItems = L.featureGroup().addTo(newMap);

    mapDisplay .on(L.Draw.Event.CREATED, function (event) {
         var layer = event.layer;
 
         drawnItems.addLayer(layer);
     });
    setMap(mapDisplay );
  }, []);
 return (
    <>
      <div
        style={{ padding: 0, margin: 0, width: "100%", height: "100vh" }}
        // ref={(el) => (mapContainer.current = el)}
        id="map"
      ></div>
    </>
  );

`

here is the versions I am using in my code

"leaflet": "^1.8.0",
"leaflet-draw": "^1.0.4",
@hlovdal
Copy link

hlovdal commented Feb 12, 2024

This is a duplicate of #1026, which also includes a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants