npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

leaflet-temporal-geojson

v0.4.0

Published

Animate GeoJSON features using an arbitrary time property

Downloads

14

Readme

leaflet-temporal-geojson NPM version NPM Downloads

A somewhat unopinionated leaflet (v1+) plugin to animate GeoJSON features using an arbitrary time property:

  • You decide how to change frames (event driven range slider components, methods calls, whatever 🤷‍♂️)
  • You control feature styling (static, dynamic, whatever 🤷‍♀️)

Screenshot

how does it work

  • features are clustered into layer 'keyframes' using supplied time property
  • keyframes are rendered depending on time key
  • features may have custom styles applied using properties

notes

  • to improve rendering performance, points are rendered as L.circleMarker vectors using L.geoJSON's pointToLayer function (i.e. to avoid use of DOM <img> for markers)

install

npm install leaflet-temporal-geojson --save

development

npm install 
npm run build

use and options

See demo for detailed example.

const layer = L.temporalGeoJSONLayer({

  // which property to use for time (expects ISO 8601 string)
  timeKey: "time",
  
  // optional function to return style 
  // see path options: https://leafletjs.com/reference-1.6.0.html#path-option
  style: function(feature) { 
    return {}; 
  },
  
  // array of geojson features
  features: [
    {
      "type": "Feature",
      "properties": {
        "age": 1,
        "time": "2005-08-22T09:01:00Z"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          156,
          -45
        ]
      }
    },
  ],

  // OPTIONAL - supply the name of a custom pane,
  // will be created if doesn't exist, defaults to overlayPane
  // https://leafletjs.com/reference-1.6.0.html#map-pane
  paneName: 'myCustomPane',

  // OPTIONAL - additional options to style point data (e.g. radius)
  // this has lower priority than styles from style()
  // https://leafletjs.com/reference-1.6.0.html#circlemarker
  circleMarkerOptions: {},

  // OPTIONAL - renderer factory
  // One of: L.canvas, L.svg (defaults to canvas)
  // Note: L.svg is not recommended due to performance overhead
  rendererFactory: L.canvas,

  // OPTIONAL - callbacks when layer is added/removed from map
  onAdd: function(){},
  onRemove: function(){},

  // OPTIONAL - function to control feature popups
  // https://leafletjs.com/reference-1.6.0.html#geojson
  popupFunction(layer) {
    return `the time here is: ${layer.feature.properties.time}`
  }

});

public methods

|method|params|description| |---|---|---| |getFrame||Get the current frame time (-1 if not set)| |getFrameKeys||Get an ascending array of all ISO times (can then be used to call setFrame)| |isActive||check if the layer is currently active on the map| |setFrame|time: {string}|display the features at the given ISO time (if calling from something like a range slider, recommended to throttle - see demo). |setStyle|style: {function}|Changes styles of GeoJSON vector layers with the given style function. Set falsey for defaults.| |getBounds|time {string}|Get the bounds at given time (falls back to bounds of current keyframe, and then bounds of first keyframe if not set).|

example data

The included example data is fictional and intended for demonstration purposes only, however - if you're interested in marine connectivity modelling you should check out some of CSIRO's work on connectivity modelling here, and here.