Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pigeon-maps

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pigeon-maps

ReactJS maps without external dependencies

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.9K
decreased by-38.14%
Maintainers
1
Weekly downloads
 
Created
Source

Pigeon Maps - ReactJS maps without external dependencies

npm version

Demonstration

Demo: https://mariusandra.github.io/pigeon-maps/ (using maps from Wikimedia)

What is it?

Pigeon

Are you tired of waiting 3 seconds to parse 200kb of Google Maps JavaScript just to display a few tiles and a marker? 140kb of minified Leaflet too much?

Welcome to the club!

This project aims to provide a performance-first React-centric extendable map engine.

We're currently at:

  • ~20KB minified
  • ~5KB gzipped

Implemented:

  • Show tiles
  • Arbitrary overlays (markers, etc)
  • Move the map by dragging
  • Move the map by touch on mobile
  • Zooming with the scroll wheel
  • Zooming by touch
  • Fractional zooming (e.g. to level 12.2)
  • Zoom without flickering (keep old tiles until new ones load)
  • Smooth animated zooming
  • Slide when dragging and letting go
  • Event handling (clicks, etc)
  • Double click and double tap zooming

Missing:

  • Double tap and then swipe touch zooming

Install

yarn add pigeon-maps

Code

See the demo for an example

import Map, { Overlay } from 'pigeon-maps'

const map = (
  <Map center={[50.879, 4.6997]} zoom={12} width={600} height={400}>
    <Overlay anchor={[50.879, 4.6997]} offset={[15, 31]}>
      <img src='pin@2x.png' width={29} height={34} alt='' />
    </Overlay>
  </Map>
)

API

Map

center - Coordinates of the map center in the format [lat, lng]

zoom - Current zoom level 12

width - Width of the component in pixels. Must be set.

height - Height of the component in pixels. Must be set.

provider - Function that returns a TMS URL: (x, y, z) => url.

animate - Animations enabled, true.

attribution - What to show as an attribution. React node or false to hide.

attributionPrefix - Prefix before attribution. React node or false to hide.

onClick - When map is clicked `function ({ event, latLng, pixel })``

onBoundsChanged - When the bounds change, function ({ center, zoom, bounds }). Use this for a controlled component, then set center and zoom when it's called.

Overlays

<Map /> takes random React components as its children. The children may have these special props:

anchor - At which coordinates [lat, lng] to anchor the overlay with the map.

offset - Offset in pixels relative to the anchor.

The children get passed these special props:

left - Pixels from the left of the map, calculated from anchor and offset

top - Pixels from the top of the map, calculated from anchor and offset

latLngToPixel - A helper function (latLng, center, zoom) that returns the position in pixels [x, y] for any [lat, lng]. The last 2 arguments are optional.

pixelToLatLng - A helper function (pixel, center, zoom) that converts any pixel coordinates [x, y] to [lat, lng]. The last 2 arguments are optional.

Use these two functions to create beautiful widgets. See the example marker component.

Add the class pigeon-drag-block to disable dragging on the overlay. Add the class pigeon-click-block to disable map background clicks on the element.

Alternatively use the <Overlay /> component. It accepts anchor, offset and classNames as its props and positions itself accordingly.

Yeah, but why pigeon??

Pigeons are experts in magnetoreception. Good pigeons can find their way home from anywhere.

Magnets were essential in making the first maps. With a good map you can find your way home from anywhere.

Thus, pigeon.

Source: https://en.wikipedia.org/wiki/Homing_pigeon


Pigeon image by Robert Claypool

FAQs

Package last updated on 20 Dec 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc