Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaflet.PolylineOffset and React #26

Open
ramdyne opened this issue Dec 10, 2020 · 1 comment
Open

Leaflet.PolylineOffset and React #26

ramdyne opened this issue Dec 10, 2020 · 1 comment

Comments

@ramdyne
Copy link

ramdyne commented Dec 10, 2020

Hi,

Has anyone been able to get this to work with current (> 17.0) React.js and react-leaflet? Just importing it after npm install doesn't do anything (two Polylines between two locations don't show an offset), I saw a hint that I was supposed to do something like at https://github.com/pajicv/react-leaflet-with-custom-plugin/blob/master/src/App.js but leafletElement is undefined.

I am at a loss ;-)

Thanks!

@Nexoid
Copy link

Nexoid commented Jan 6, 2021

Hey @ramdyne, I don't know if you're still having issue with this plugin, but there is fortunately nothing tricky about this :)

All you need to do is importing import 'leaflet-polylineoffset' in your component, and set offset props to Polyline element :

import React, { FC } from 'react'
import 'leaflet-polylineoffset'
import { Polyline } from 'react-leaflet'
const CustomPolyline: FC = (props) => {
  return <Polyline offset={2} {...props} />
}

Hope it helps !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants