1.2.1 • Published 3 months ago

@nazka/map-gl-js-spiderfy v1.2.1

Weekly downloads
-
License
BSD-3-Clause Lice...
Repository
github
Last release
3 months ago

map-gl-js-spiderfy · npm version PRs Welcome

Spiderfy plugin for maplibre-gl and mapbox-gl. This plugin creates the spiderfication in the canvas itself instead of on top of it. This allows for more advanced interactions with the map and its content. This plugin builds further upon the cluster functionality of maplibre and mapbox.

This opensource project is maintained by nazka mapps, we gladly welcome any contributions!

We try to stand out by:

  • compatibility with both mapbox-gl and maplibre-gl
  • rendering in the canvas (with 3D rendering support)
  • a lot of customizable properties and options (see advanced demo)

A nice extra, since the spiderfication is part of the canvas, generating screenshots of it is really easy

screenshot (15)

Demo examples

Maplibre ^4.0.0

Mapbox and older Maplibre versions

Usage

Install the npm package:

npm install @nazka/map-gl-js-spiderfy

Simple setup:

import Spiderfy from '@nazka/map-gl-js-spiderfy';

...

// create a new spiderfy object
const spiderfy = new Spiderfy(map, {
  onLeafClick: f => console.log(f),
  minZoomLevel: 12,
  zoomIncrement: 2,
});

// enable spiderfy on a layer
// IMPORTANT: the layer must have a cluster source
spiderfy.applyTo('markers');

Please refer to the demo examples first if you're having issues.

Docs

New Spiderfy instance

new Spiderfy(map, options)

Options

  • map - reference to a maplibre-gl or mapbox-gl instance object

  • options

    • onLeafClick - allows to put an action on the clicked leaf function (feature, event)

    • onLeafHover - allows to put an action on the hovered leaf function (feature, event)

    • minZoomLevel - allows spiderfication starting from this zoom level number

    • zoomIncrement - if minZoomLevel is not reached on cluster click, the map will zoom by this amount instead number

    • closeOnLeafClick - remove the spiderfication on leaf click boolean

    • circleSpiralSwitchover - number of leaves required to switch from circle to spiral spiderfication number

    • circleOptions - options that are specific to circle spiderfications object

      • leavesSeparation - distance between the spiderfied leaves in pixels number

      • leavesOffset - moves the leaves relative to the parent cluster in pixels arraydefault: 0, 0]

    • spiralOptions - options that are specific to spiral spiderfications, these interact with each other and will probably all require some tweaking when changing one of them object

      • legLengthStart - the starting length of the spider leg in pixels number

      • legLengthFactor - the growth factor of the next leg in pixels number

      • leavesSeparation - distance between the spiderfied leaves in pixels number

      • leavesOffset - moves the leaves relative to the parent cluster in pixels arraydefault: 0, 0]

    • spiderLegsAreHidden - don't render the spider legs boolean

    • spiderLegsWidth - the width of the spider legs in pixel number

    • spiderLegsColor - the color of the spider legs string

    • spiderLeavesLayout - your own style layout attributes ('icon-offset' can't be used) object

    • spiderLeavesPaint - your own style paint attributes object

    • maxLeaves - limits the amount of leaves that can be in a spiderfication number

    • renderMethod - set to "3D" for this experimental render feature string

Functions

  • applyTo(layerId) apply the spiderfier on a layer function

    • layerId maplibre/mapbox layer id string
  • unspiderfyAll() clears any active spiderfication from the map function

Contributing

If an issue has a help wanted tag this means you can pick it up, just let us know.

You will have to create a fork of this project with your own branch and work on there. Once that's done you can create a pull request on this repo. One of the maintainers will have a look at it and give the necessary feedback/questions or merge it into this project.

Take a look at this repo if you haven't made a contribution to a project on github yet.

License

This package is published under the BSD-3-Clause License. Copyright (c) 2022, nazka mapps

1.2.0

3 months ago

1.2.1

3 months ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

2 years ago

1.0.0-beta

2 years ago

1.0.0-alpha.27

2 years ago

1.0.0-alpha.26

2 years ago

1.0.0-alpha.25

2 years ago

1.0.0-alpha.24

2 years ago

1.0.0-alpha.23

2 years ago

1.0.0-alpha.22

2 years ago

1.0.0-alpha.21

2 years ago

1.0.0-alpha.20

2 years ago

1.0.0-alpha.19

2 years ago

1.0.0-alpha.18

2 years ago

1.0.0-alpha.17

2 years ago

1.0.0-alpha.16

2 years ago

1.0.0-alpha.15

2 years ago

1.0.0-alpha.14

2 years ago

1.0.0-alpha.13

2 years ago

1.0.0-alpha.12

2 years ago

1.0.0-alpha.11

2 years ago

1.0.0-alpha.10

2 years ago

1.0.0-alpha.9

2 years ago

1.0.0-alpha.8

2 years ago

1.0.0-alpha.7

2 years ago

1.0.0-alpha.6

2 years ago

1.0.0-alpha.5

2 years ago

1.0.0-alpha.4

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago