Socket
Socket
Sign inDemoInstall

ngx-leaflet-gridlayer

Package Overview
Dependencies
5
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-leaflet-gridlayer

This is a library used to easily create grid layers according to the data entered by the user in leaflet maps.


Version published
Weekly downloads
4
Maintainers
1
Install size
160 kB
Created
Weekly downloads
 

Readme

Source

ngx-leaflet-gridlayer

This is a library for angular in support of @asymmetrik/ngx-leaflet to facilitate the process of building grid layers on top of the map and visualize aggregator data on each tile. The library aims to remove the burden of such tasks while keeping the performance and being responsive.

Demo

Demo

Installation

Install ngx-leaflet-gridlayer with npm

  npm install ngx-leaflet-gridlayer

Import 'NgxLeafletGridlayerModule' in the module you are using the map or top module.

import { NgxLeafletGridlayerModule } from 'ngx-leaflet-gridlayer';

@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    // ...
    NgxLeafletGridlayerModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

In the component where this should be integrated import 'NgxLeafletGridlayerService'.

import { NgxLeafletGridlayerService } from 'ngx-leaflet-gridlayer';

// Add map property which will hold the map reference
map!: Map;

// Add the service in the constructor for use
constructor(private _gridlayerService: NgxLeafletGridlayerService) {}

// onMapReady is a method that is triggered when the map is ready, so use it to get the reference to the map and pass it to createGridLayer() together with the data which should be of type InputData.
onMapReady(map: Map): void {
    this.map = map;   
    this._gridlayerService.createGridLayer(inputData, this.map)
};

Data type

The service should be supplied with data of the following format:

interface InputData {
    data: Data[],
    tileOutlineColor: string,   
    backgroundColor: {
        fewItems: {
            numberOfItems: number,
            backgroundColor: string
        },
        someItems: {
            numberOfItems: number,
            backgroundColor: string
        },
        manyItems: {
            numberOfItems: number,
            backgroundColor: string
        }
    },
    hoverBackgroundColor: string,
    hoverOutlineColor: string,
}

interface Data {
  title: string,
  description: string,
  boundingCoordinates: BoundingCoordinates,
}

interface BoundingCoordinates {
  eastBoundingCoordinate: number, 
  westBoundingCoordinate: number,
  northBoundingCoordinate: number,
  southBoundingCoordinate: number
};

where different color can be provided for different total number of items as well as the number itself.

Here is an example of data:

data= {
  tileOutlineColor: 'red',
  backgroundColor: {
    fewItems: {
      numberOfItems: 3,
      backgroundColor: 'green'
    },
    someItems: {
      numberOfItems: 6,
      backgroundColor: 'purple'
    },
    manyItems: {
      numberOfItems: 9,
      backgroundColor: 'yellow'
    }
  },
  hoverBackgroundColor: 'brown',
  hoverOutlineColor: 'orange',
  data: [
    { 
      title: 'test1',
      description: 'test2',
      boundingCoordinates: {
        eastBoundingCoordinate: 18,
        westBoundingCoordinate: 22,
        northBoundingCoordinate: 17,
        southBoundingCoordinate: 16
      }
    },
    { 
      title: 'test1',
      description: 'test2',
      boundingCoordinates: {
        eastBoundingCoordinate: 30,
        westBoundingCoordinate: 40,
        northBoundingCoordinate: 35,
        southBoundingCoordinate: 64
      }
    }
  ]
}

Authors

Contributing

Contributions are always welcome!

See contributing.md in the repo for more details.

Please adhere to this project's code of conduct.

License

See LICENSE in repository for details.

Keywords

FAQs

Last updated on 26 Apr 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc