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

map-overlay

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-overlay

Overlay simple polygons on a rastermap instance

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

map-overlay

Overlay simple polygons on a rastermap instance

Initialization

mapOverlay.init takes a parameters object with the following properties:

  • canvas: an HTML canvas element
  • map: a rastermap instance (or equivalent). MUST have a method named xyToMapPixels, for converting x/y coordinates in the map's projection to pixel indices from the top left corner of the map
  • width, height: the pixel dimensions of the rastermap drawingbuffer

API

Initialization returns an object with the following methods:

  • draw(polygon, mapChanged): Draws polygon on the overlay canvas.
    • polygong must be an array of points, where each point is a two-element array containing floating point numbers.
    • mapChanged is a flag indicating whether the underlying map coordinates have changed since the last draw call.
  • reset(): Clears the canvas and the stored polygon

Note that the .draw method will do nothing if all of the following conditions are true:

  • polygon is the same as the last call
  • overlay canvas has not changed size
  • mapChanged is false

If the supplied polygon contains exactly two points, they will be treated as the top left and bottom right corners of a rectangle, and drawn using the Canvas2D strokeRect method.

Keywords

FAQs

Package last updated on 01 Feb 2022

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