🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

@freenow/react-polygon-editor

Package Overview
Dependencies
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freenow/react-polygon-editor

A react component for displaying and drawing geo polygons

1.0.1
Source
npm
Version published
Weekly downloads
5
-44.44%
Maintainers
6
Weekly downloads
 
Created
Source

@freenow/react-polygon-editor

Table of contents

  • About
  • Getting started
  • Components
  • How to run locally
  • Contribution

About

React Polygon Editor provides react components for displaying and editing polygons. We use leaflet for rendering maps. And typescript to provide a strongly typed interface.

Getting started

First install @freenow/react-polygon-editor:

npm i -S @freenow/react-polygon-editor

Make sure you have also installed all peer dependencies. Have a look at package.json for more information.

inject the leaflet css style.

Import 'leaflet/dist/leaflet.css';

You can also link the css style from a CDN in your index.html

<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css" />

Components

PolygonDraw

Props

  • polygon: Coordinate[]
  • boundary?: Coordinate[]
  • initialCenter?: Coordinate (The initial center will be used to localize the map on the first render if no polygon or boundary polygon were provided)
  • initialZoom?: number (The initial zoom will be used to localize the map on the first render if no polygon or boundary polygon were provided)
  • editable?: boolean (Allows enabling and disabling polygon editing. Default value: true)
  • onChange?: (polygonCoordinates: Coordinate[], isValid: boolean) => void

The initialCenter and initialZoom props are applicable only when both the polygon and the boundary coordinates are empty. This flow explains which parameters are used to focus the map:

Focus flow

For more details, have a look at the Component definition in PolygonDraw

How to run locally

You can run the library locally. We use storybook to illustrate what can be done with the components.

Simply run:

npm i && npm start

Contribution

  • Discuss the contribution with the maintainers
  • Make sure the the code is well tested and adheres to code convention
  • Create a pull request

Keywords

leaflet

FAQs

Package last updated on 12 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts