1.1.1 • Published 2 years ago

spline-wrapper v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Spline Wrapper

An unofficial plugin component for react-map-gl

Available functions

  • Create curved lines (No more straight lines with sharp corners! 😉)
  • Add arrow to start/center/end of lines (Hopefully, this is helpful! 🥳)

Here is a screenshot of the output after using both functions provided: image
Run this project to see the demo! (Don't forget to add the token and map style first)

Props

PropsDescription
childrenSource component
arrow{icon, position} object where icon sets the loaded arrow image's name and position can be set to either start,center or end
linesarray of {from:[longitude, latitude], to:[longitude, latitude], properties:{}}

Getting Started

Setup

How to use SplineWrapper

  • Import the component: import SplineWrapper from "spline-wrapper"
  • Already have an existing Source and Layer components? Don't have them yet? Not an issue! 😉
<Map>
  <SplineWrapper>
    //Copy&Paste or Create your Source and Layer components here
    <Source data={data}>
      <Layer/>
      ...
    </Source>
  </SplineWrapper>
</Map
<SplineWrapper arrow={{
  icon:"arrow", // Pass the name of the loaded/added arrow image
  position:"start" // Can be either start, center or end
}}>
  ...
</SplineWrapper>
  • Want curvy lines? Use lines props:
const lines = [
  {
    from:[51.5072, -0.1276],  // longitude, latitude
    to:[48.8566, 2.3522],     // longitude, latitude
    properties:{...}  // optional
  },
  {
    from:[48.8566, 2.3522],  // longitude, latitude
    to:[4.2105, 101.9758],     // longitude, latitude
    properties:{...}  // optional
  }
]
<SplineWrapper lines={lines}>
  ...
</SplineWrapper>

Still confused? Check out the example here 😁

Notes 📝

  • There is no control points prop (to control the curve level/intensity) available at the moment but might be added if lots of people need it
  • Curves are only applied to lines generated from the lines prop
  • Load and add icon image before passing the name to arrow prop
  • The arrows are applied to every feature of type LineString (including those generated from lines prop)
  • The arrow points to the direction of the line
  • Since this is just a wrapper component, you should have almost full control over react-map-gl related uses

Enjoy!

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago