The standard Leaflet marker icon, but in different color variations, for simple use cases.
This is a modernized fork of patrickp-rthinfo/leaflet-color-markers, which is in turn a fork of pointhi/leaflet-color-markers. With this, the first commit to this project can be traced back to late 2013.
Note that the Leaflet marker icon is originally contributed to the Leaflet project, and is not the work of this library. The work here is to make that marker icon available in more colors.
via NPM:
npm install @vectorial1024/leaflet-color-markers
This library is a successor of leaflet-color-markers. That NPM library, for the lack of better words, actually does nothing.
A demo is included in the same repo. It showcases a simple Leaflet map with a colored marker from this package.
You may try it locally with the following steps:
- Clone this repo
npm run build-demo
- Open
demo.html
in your internet browser - See a minimally usable Leaflet map with a colored marker in it
Add a simple marker using the green icon template to a Leaflet map:
import { greenIcon } from "@vectorial1024/leaflet-color-markers";
// we assume the map is already defined
const map = L.map('theMap');
L.marker([51.5, -0.09], { icon: greenIcon }).addTo(map);
We recommend using the more modern ESM style (import
) to handle dependencies, but if CJS (require()
) is required, you can still do this:
// require() also works, but we recommend using the import if possible
const LCM = require("@vectorial1024/leaflet-color-markers");
const greenIcon = LCM.greenIcon;