-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ccc2c08
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |