Jacob Mason
Jacob Mason

Reputation: 1405

Do I have to import leaflet's CSS file?

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?

Upvotes: 2

Views: 11574

Answers (1)

Zeeshan Hassan Memon
Zeeshan Hassan Memon

Reputation: 8325

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.

Upvotes: 3

Related Questions