Git Product home page Git Product logo

ngx-leaflet-markercluster's Introduction

@asymmetrik/ngx-leaflet-markercluster

Build Status

Extension to the @asymmetrik/ngx-leaflet package for Angular.io Provides leaflet.markercluster integration into Angular.io projects. Compatible with Leaflet v1.x and leaflet.markercluster v1.x Supports Angular v10, Ahead-of-Time compilation (AOT), and use in Angular-CLI based projects

Table of Contents

Install

Install the package and its peer dependencies via npm:

npm install leaflet @asymmetrik/ngx-leaflet
npm install leaflet.markercluster @asymmetrik/ngx-leaflet-markercluster

If you intend to use this library in a typescript project (utilizing the typings), you will need to also install the leaflet typings via npm:

npm install @types/leaflet @types/leaflet.markercluster

Usage

This plugin is used with the Angular.io Leaflet plugin.

The first step is to follow the instructions to get @asymmetrik/ngx-leaflet working. Next, follow a similar process to install and configure this plugin. Generally, the steps are:

  • Install this package and its dependencies (see above).
  • Import the leaflet.markercluster stylesheet (i.e., node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css). Follow the same process as documented in @asymmetrik/ngx-leaflet.
  • Import the LeafletMarkerClusterModule into your Angular application module and local module (if applicable).
  • Create and configure a map (see docs below and/or demo)

To create a map, use the leaflet attribute directive. This directive must appear first. You must specify an initial zoom/center and set of layers either via leafletOptions or by binding to leafletZoom, leafletCenter, and leafletLayers.

<div style="height: 400px;"
     leaflet
     [leafletOptions]="options"
     [leafletMarkerCluster]="markerClusterData"
     [leafletMarkerClusterOptions]="markerClusterOptions">
</div>

Finally, to initialize and configure the leaflet markercluster plugin, use the following attribute directives:

leafletMarkerCluster

This attribute is an attribute directive that initiates the marker cluster plugin and binds the marker data.

leafletMarkerClusterOptions

Input binding for the options to be passed directly to the marker cluster plugin upon creation. These options are only currently processed at creation time.

The options object is passed through to the leaflet.markercluster object. Therefore, you can reference their documentation for help configuring this plugin.

Getting a reference to the MarkerCluster Layer

There is an optional output event emitter that will expose the markercluster group being used by the plugin called leafletMarkerClusterReady. See the following example:

<div style="height: 400px;"
     leaflet
     [leafletOptions]="options"
     [leafletMarkerCluster]="markerClusterData"
     [leafletMarkerClusterOptions]="markerClusterOptions"
     (leafletMarkerClusterReady)="markerClusterReady($event)">
</div>
markerClusterReady(markerCluster: L.MarkerClusterGroup) {
	// Do stuff with group
}

Contribute

PRs accepted. If you are part of Asymmetrik, please make contributions on feature branches off of the develop branch. If you are outside of Asymmetrik, please fork our repo to make contributions.

License

See LICENSE in repository for details.

ngx-leaflet-markercluster's People

Contributors

hlovdal avatar iskatel-ua avatar luketherrien avatar reblace avatar

Watchers

 avatar  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.