Giter Site home page Giter Site logo

nonconforme / leaflet.markercluster.placementstrategies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adammertel/leaflet.markercluster.placementstrategies

0.0 1.0 0.0 661 KB

Impelements new possibilities to place markers for Leaflet.MarkerCluster plugin

Home Page: https://adammertel.github.io/Leaflet.MarkerCluster.PlacementStrategies/demo/demo1.html

JavaScript 100.00%

leaflet.markercluster.placementstrategies's Introduction

Leaflet.MarkerCluster.PlacementStrategies

subplugin for the Leaflet.MarkerCluster that implements new possibilities how to place clustered chidren markers

Demo:

random data demo

How to use:

  1. include Leaflet and Leaflet.MarkerCluster libraries (cdnjs, ungkg, npm install...)

  2. download and include built leaflet-markercluster.placementstrategies.js or leaflet-markercluster.placementstrategies.src.js file from dist folder.

  3. create L.markerClusterGroup instance, add markers and define placement strategy and othe options:

var markers = L.markerClusterGroup({
  spiderLegPolylineOptions: {weight: 0},
  clockHelpingCircleOptions: {weight: .7, opacity: 1, color: 'black', fillOpacity: 0, dashArray: '10 5'},

  elementsPlacementStrategy: 'clock',
  helpingCircles: true,

  spiderfyDistanceSurplus: 25,
  spiderfyDistanceMultiplier: 1,

  elementsMultiplier: 1.4,
  firstCircleElements: 8

});

for (var i = 0; i < 10000; i++) {
  var circle = L.circleMarker([Math.random() * 30, Math.random() * 30], {fillOpacity: 0.7, radius: 8, fillColor: 'red',
  color: 'black'});
  markers.addLayer(circle);
}

map.addLayer(markers);

How to build:

  1. install npm modules npm install
  2. run build command npm run build

npm start will watch and build on changes

Placement Strategies

  • default - one-circle strategy (up to 8 elements*, else spiral strategy)

  • spiral - snail/spiral placement

    image

  • one-circle - put all the elements into one circle

    image

  • concentric - elements are placed automatically into concentric circles, there is a maximum of 4 circles

    image

  • clock - fills circles around the cluster marker in the style of clocks

    image

  • clock-concentric - in the case of one circle, elements are places based on the concentric style, more circles are dislocated in the clock style

  • original-locations - elements are placed at their original locations

    image

*can be changed - _circleSpiralSwitchover variable in the original markerCluster code

Helping Circles

new type geometry called "helpingCircle" is added and can be used for the last three strategies to make the cluster more visually-consistent.

Options

  • elementsPlacementStrategy (default value 'clock-concentric') - defines the strategy for placing markers in cluster, see above
  • spiderfiedClassName (default value false) - if a value of type string is defined, the code will assign this value to the spiderfied markers

Options that are valid for placement strategies 'concentric', 'clock' and 'clock-concentric'

  • firstCircleElements (default value 10) - number of elements in the first circle

  • elementsMultiplier (default value 1.5) - multiplicator of elements number in the next circle

  • spiderfyDistanceSurplus (default value 30) - value to be added to each new circle distance

  • helpingCircles (default value true) - will draw helping circles

  • helpingCircleOptions (default value { fillOpacity: 0, color: 'grey', weight: 0.6 } ) - possibility to specify helpingCircle style

Notes:

  • this subplugin was not tested with the animations turned on (animation and animateAddingMarkers variables)
  • circleMarkers should be preferred to markers
  • use with L.SVG renderer if possible (L.Canvas renderer has some technical issues with some visual properties, see #6)

leaflet.markercluster.placementstrategies's People

Contributors

adammertel avatar kuuup-at-work avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.