coryasilva / Leaflet.ExtraMarkers

Custom Markers for Leaflet JS based on Awesome Markers
MIT License
331 stars 125 forks source link

NPM Example in Readme #53

Closed gregnalor closed 4 years ago

gregnalor commented 4 years ago

Hi There,

Looks great - however I can't for the life of me work out how to get it working in an NPM environment. No matter what I do, I keep getting 'L.ExtraMarkers undefined' errors.

I'm not a newb but also not experienced in how to do NPM includes that override one another like leaflet and extra-markers.

Would it be possible to include a minimal NPM example in the readme?

Many thanks,

Greg.

gregnalor commented 4 years ago

OK - So, I figured it out a solution - not necessarily the best or correct. I'll leave it here for anyone interested. Would still be good to have a formal version in the NPM readme :-).

React/Typescript/ESLint environment...

import L from 'leaflet'
// eslint-disable-next-line  (needed as we don't reference ExtraMarkers after the next line so ESLint complains)
import * as ExtraMarkers from 'leaflet-extra-markers'; // or else TS complains about the L extension
import '@fortawesome/fontawesome-free/css/all.css';  //e.g. using FA icons
import 'leaflet-extra-markers/dist/css/leaflet.extra-markers.min.css'; //import the LEM css
require( 'leaflet-extra-markers'); //Do the L extension.