npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-leaflet-marker

v2.1.1

Published

Custom markers for react-leaflet maps.

Downloads

3,094

Readme

react-leaflet-marker

Custom markers for react-leaflet maps.

You can use any react component with version of react-leaflet 3.x.x || 4.x.x

npm types GitHub Actions CI License

Support zoom animation

animation

Demo

Install

React 18 react-leaflet 4

npm i react-leaflet-marker --save

React 17 react-leaflet 3

npm i [email protected] --save

Get started

import React from "react";
import { MapContainer } from "react-leaflet";
import { MarkerLayer, Marker } from "react-leaflet-marker";

const ReactMarker = () => (
    <MapContainer
        {/* ...MapContainerProps react-leaflet */}
        center={[55.796391, 49.108891]}
        zoom={10}
    >
        <MarkerLayer>
            <Marker
                position={[55.796391, 49.108891]}
            >
                <div>Hi, i'm a react element</div>
            </Marker>
        </MarkerLayer>
    </MapContainer>
);

export default ReactMarker;

Examples

Simple marker with flexible size

Markers without size can't take placement props.

simple

<MarkerLayer>
    <Marker
        position={[55.796391, 49.108891]}
    >
        <div style={{
            background: 'red'
        }}>
            simple{'\u00A0'}marker
        </div>
    </Marker>
</MarkerLayer>

Marker with fixed size

Just add size props. It is the best practice the most cases.

placement

<MarkerLayer>
    <Marker
        position={[55.796391, 49.108891]}
        size={[80, 20]} // required for placement
        // you can use optional `placement`
        placement="center" // "top", "bottom"
    >
        <div style={{
            background: 'red',
            textAlign: 'center'
        }}>
            center
        </div>
    </Marker>
</MarkerLayer>

Rise on hover

The marker will get on top of others when you hover the mouse over it.

rise on hover

<MarkerLayer>
    <Marker
        position={[55.796391, 49.108891]}
        size={[80, 40]}
        interactive // required for riseOnHover
        riseOnHover
    >
        <div style={{
            background: 'red',
            textAlign: 'center'
        }}>
            First marker
        </div>
    </Marker>
</MarkerLayer>

Use any react component as marker

For example, I used antd dropdown and custom icons

cover

Props

| Name | Default | Type | Description | | ---------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --- | | position | - | LatLngExpression | Lat Lng coordinates | | innerRef? | - | MutableRefObject | | | riseOnHover? | false | bool | If true, the marker will get on top of others when you hover the mouse over it.If true, the marker will get on top of others when you hover the mouse over it. | | riseOffset? | 250 | number | The z-index offset used for the riseOnHover feature. | | zIndexOffset? | 0 | number | By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively). | | interactive? | false | bool | If set false, the marker won't respond to mouse | | size? | - | [width: number, height: number] | Size marker. Required for placement | | placement? | center | string | One of top, center, bottom |