1.1.2 • Published 12 months ago

map-circle-control v1.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
12 months ago

NPM version Build Status Dependency Status

map-circle-control

Draggable circle to be used with map renderer. Click here to see the demo page.

Install

$ npm install --save map-circle-control

Usage in standard container

const makeCircle = require('map-circle-control');

let circle = makeCircle({
  container: document.querySelector('.map'), // dom element to which circle will be added
  center: [ 250, 200 ],                      // offset in the container
  radius: 175                                // radius in pixels
});

// `radius-changed` and `center-changed` events are supported
circle.on('radius-changed', function() {
  console.log('New radius:', circle.radius);
});
circle.on('center-changed', function() {
  console.log('New center:', circle.center);
});

// `radius` and `center` can be used to move and/or resize the circle
circle.radius = 120;
circle.center = [10, 15];

Usage with mapbox-gl

Circle implements IControl and thus can be used with mapbox-gl or any other compatible map. Cirle is using getContainer, project, and unproject methods only.

let map = new mapboxgl.Map(/* options */);
const makeCircle = require('map-circle-control');

let circle = makeCircle({
  center: [ 250, 200 ],                      // offset in the container
  radius: 175                                // radius in pixels
});

// display circle on the map
map.add(circle);

// `radius-changed` and `center-changed` events are supported
circle.on('radius-changed', function() {
  console.log('New radius in meters:', circle.geoRadius);
});
circle.on('center-changed', function() {
  console.log('New center as [longiturde, latitude]:', circle.geoCenter);
});

// `radius` and `center` can be used to move and/or resize the circle
circle.geoRadius = 1200;           // 1.2 km
circle.geoCenter = [0.1278, 51.5074]; // London

License

MIT © Damian Krzeminski

1.1.2

12 months ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.0

6 years ago