2

I'm using Node / React / Webpack with leaflet. I installed leaflet using npm and in my map component I import 'leaflet'; which works fine for the js.

However, the map does not look correct due to the css not working correctly, however images stored in the leaflet/dist/images seem to work fine. In order to get the css to work I have to also import 'leaflet/dist/leaflet.css' but it feels to me like I shouldn't have to and that it should be included with the first import statement?

Jacob Mason
  • 1,355
  • 5
  • 14
  • 28
  • Yes you have to have, see this link might be useful: [leaflet-css webpack require](http://stackoverflow.com/questions/33732066/webpack-requirenode-modules-leaflet-leaflet-css) – Zeeshan Hassan Memon Mar 04 '16 at 13:18
  • When I miss the CSS, I get a crazy tiled set that is all in the wrong order and draggable in a weird way; if you seem to end up with that then you are missing the CSS. So yep def need it:) – tempranova Mar 07 '16 at 07:15
  • Possible duplicate of [Example of how to load static CSS files from node\_modules using webpack?](http://stackoverflow.com/questions/34311656/example-of-how-to-load-static-css-files-from-node-modules-using-webpack) – Drew Jul 15 '16 at 00:11

1 Answers1

3

Yes, you have to have, see this link might be useful:

leaflet-css webpack require

I omitted its CSS in an ionic project but copied a few necessary lines to avoid a broken map UI.

Zeeshan Hassan Memon
  • 8,105
  • 4
  • 43
  • 57