Git Product home page Git Product logo

mapbox-geo-circle-layer's Introduction

English / 日本語

mapbox-geo-circle-layer

Renders a simple circle on a Mapbox GL JS map.

Getting started

How to install

Please run the following command:

npm install https://github.com/codemonger-io/mapbox-geo-circle-layer.git#v0.1.0

Prerequisites

This library is intended to work with Mapbox GL JS v2.x.

Usage

The following snippet adds a custom layer (id="example-circle") that renders a transparent blue circle with the radius of 100 meters around Tokyo Station:

import { GeoCircleLayer } from 'mapbox-geo-circle-layer';
// suppose map: mapbox-gl.Map
map.addLayer(new GeoCircleLayer('example-circle', {
    radiusInMeters: 100,
    center: { lng: 139.7671, lat: 35.6812 },
    fill: { red: 0.25, green: 0.25, blue: 0.5, alpha: 0.5 },
}));

You will see something like the following, example circle

Updating properties

You can change the following properties of a GeoCircleLayer after creating it.

If you change any of the above properties, GeoCircleLayer triggers repaint of the map.

API documentation

Please refer to the api-docs/markdown folder.

Development

Prerequisites

Node.js version 14 or higher is required to build this library.

Installing dependencies

npm run install

Building the library

npm run build

Generating the API documentation

npm run build:doc

This also runs npm run build.

Running type check

You can run a type checker without building the library.

npm run type-check

Running tests

npm test

Alternatives to this library

Built-in circle layer

Mapbox GL JS has a built-in circle layer. It can render multiple circles on a layer, but you have to specify radiuses in pixels (screen units). So it is not suitable for rendering a shape that circles a geographical area.

mapbox-gl-circle

mapbox-gl-circle offers more features than this library does. mapbox-gl-circle has an optional feature that enables interactive editing of circles. You might prefer this library for simplicity.

mapbox-gl-draw-circle

mapbox-gl-draw-circle also offers more features than this library does. mapbox-gl-draw-circle is actually implemented on top of mapbox-gl-circle. You might prefer this library for simplicity.

mapbox-geo-circle-layer's People

Contributors

kikuomax avatar

Watchers

 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.