Skip to content

Commit

Permalink
seed
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwhittemore committed Jul 17, 2017
0 parents commit ccc2c08
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Mapbox Draw Static Mode

This is a custom mode for [@mapbox/mapbox-gl-draw]() that displays data stored in Draw but does not let the user interact with it.

This mode used to be one of the core modes prior to the `v1.0.0` release of Mapbox Draw.

## Usage

To install:

`npm i @mapbox/mapbox-gl-draw-static-mode`

To add to MapboxDraw:

```js
var StaticMode = require('@mapbox/mapbox-gl-draw-static-mode');

var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [40, -74.50],
zoom: 9
});

var modes = MapboxDraw.modes;
modes.static = StaticMode;
var Draw = new MapboxDraw({ modes: modes });

map.addControl(Draw)

map.on('load', function() {
Draw.changeMode('static');
});
```


10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var StaticMode = module.exports = {};

StaticMode.onSetup = function() {
this.setActionableState(); // default actionable state is false for all actions
return {};
};

StaticMode.toDisplayFeatures = function(state, geojson, display) {
display(geojson);
};
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@mapbox/mapbox-gl-draw-static-mode",
"version": "1.0.0",
"description": "a static geojson plugin for mapbox-gl-draw",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mapbox/mapbox-gl-draw-static-mode.git"
},
"keywords": [
"mapbox",
"mapbox-gl",
"mapbox-gl-draw",
"geojson"
],
"author": "Matthew Whittemore",
"license": "ISC",
"bugs": {
"url": "https://github.com/mapbox/mapbox-gl-draw-static-mode/issues"
},
"homepage": "https://github.com/mapbox/mapbox-gl-draw-static-mode#readme"
}

0 comments on commit ccc2c08

Please sign in to comment.