Skip to content

Commit

Permalink
Remove references to static mode
Browse files Browse the repository at this point in the history
  • Loading branch information
oodavid committed Oct 28, 2021
1 parent bab1fa2 commit ec28524
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 127 deletions.
18 changes: 0 additions & 18 deletions debug/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
/* global mapboxgl, MapboxGeocoder, MapboxDraw */

const StaticMode = {};

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

StaticMode.toDisplayFeatures = function(state, geojson, display) {
display(geojson);
};

// Parse the access_token out of the url
const args = location.search.replace(/^\?/, '').split('&').reduce((o, param) => {
const keyvalue = param.split('=');
Expand All @@ -34,7 +23,6 @@ map.addControl(new MapboxGeocoder({
map.addControl(new mapboxgl.NavigationControl(), 'top-left');

const modes = MapboxDraw.modes;
modes.static = StaticMode;
const Draw = window.Draw = new MapboxDraw({ modes });
let drawIsActive = true;
map.addControl(Draw, 'bottom-right');
Expand Down Expand Up @@ -99,10 +87,4 @@ map.on('load', () => {
Draw.changeMode('draw_polygon');
};

// Jump into static mode via a custom UI element
const startStatic = document.getElementById('start-static');
startStatic.onclick = function() {
Draw.changeMode('static');
};

});
1 change: 0 additions & 1 deletion debug/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<body>
<div id='map'></div>
<div class='start-draw' >
<div id='start-static'>STATIC</div>
<div id='start-point'>POINT</div>
<div id='start-line'>LINE</div>
<div id='start-polygon'>POLYGON</div>
Expand Down
53 changes: 6 additions & 47 deletions docs/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mapbox.Draw({

### lines and polygons

With this style, all line and polygon features are have dashed red outline and transparent fill while being drawn, including the point vertices. When the Draw mode is changed the 'static', these features will be drawn with solid black outline and transparent fill. Point vertices use the same point filter, and render these points twice: once as a larger-radius halo, and again as the vertex inset point.
With this style, all line and polygon features are have dashed red outline and transparent fill while being drawn, including the point vertices. Point vertices use the same point filter, and render these points twice: once as a larger-radius halo, and again as the vertex inset point.

```js
mapbox.Draw({
Expand All @@ -52,7 +52,7 @@ mapbox.Draw({
{
"id": "gl-draw-line",
"type": "line",
"filter": ["all", ["==", "$type", "LineString"], ["!=", "mode", "static"]],
"filter": ["all", ["==", "$type", "LineString"]],
"layout": {
"line-cap": "round",
"line-join": "round"
Expand All @@ -67,7 +67,7 @@ mapbox.Draw({
{
"id": "gl-draw-polygon-fill",
"type": "fill",
"filter": ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
"filter": ["all", ["==", "$type", "Polygon"]],
"paint": {
"fill-color": "#D20C0C",
"fill-outline-color": "#D20C0C",
Expand All @@ -90,7 +90,7 @@ mapbox.Draw({
{
"id": "gl-draw-polygon-stroke-active",
"type": "line",
"filter": ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
"filter": ["all", ["==", "$type", "Polygon"]],
"layout": {
"line-cap": "round",
"line-join": "round"
Expand All @@ -105,7 +105,7 @@ mapbox.Draw({
{
"id": "gl-draw-polygon-and-line-vertex-halo-active",
"type": "circle",
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]],
"paint": {
"circle-radius": 5,
"circle-color": "#FFF"
Expand All @@ -115,52 +115,11 @@ mapbox.Draw({
{
"id": "gl-draw-polygon-and-line-vertex-active",
"type": "circle",
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]],
"paint": {
"circle-radius": 3,
"circle-color": "#D20C0C",
}
},

// INACTIVE (static, already drawn)
// line stroke
{
"id": "gl-draw-line-static",
"type": "line",
"filter": ["all", ["==", "$type", "LineString"], ["==", "mode", "static"]],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": "#000",
"line-width": 3
}
},
// polygon fill
{
"id": "gl-draw-polygon-fill-static",
"type": "fill",
"filter": ["all", ["==", "$type", "Polygon"], ["==", "mode", "static"]],
"paint": {
"fill-color": "#000",
"fill-outline-color": "#000",
"fill-opacity": 0.1
}
},
// polygon outline
{
"id": "gl-draw-polygon-stroke-static",
"type": "line",
"filter": ["all", ["==", "$type", "Polygon"], ["==", "mode", "static"]],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": "#000",
"line-width": 3
}
}
]
});
Expand Down
3 changes: 1 addition & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ export const modes = {
DRAW_POLYGON: 'draw_polygon',
DRAW_POINT: 'draw_point',
SIMPLE_SELECT: 'simple_select',
DIRECT_SELECT: 'direct_select',
STATIC: 'static'
DIRECT_SELECT: 'direct_select'
};

export const events = {
Expand Down
66 changes: 7 additions & 59 deletions src/lib/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export default [
'type': 'fill',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
['==', '$type', 'Polygon']
],
'paint': {
'fill-color': '#3bb2d0',
Expand Down Expand Up @@ -39,8 +38,7 @@ export default [
'type': 'line',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
['==', '$type', 'Polygon']
],
'layout': {
'line-cap': 'round',
Expand Down Expand Up @@ -70,8 +68,7 @@ export default [
'type': 'line',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'LineString'],
['!=', 'mode', 'static']
['==', '$type', 'LineString']
],
'layout': {
'line-cap': 'round',
Expand Down Expand Up @@ -104,8 +101,7 @@ export default [
'type': 'circle',
'filter': ['all',
['==', 'meta', 'vertex'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
['==', '$type', 'Point']
],
'paint': {
'circle-radius': 5,
Expand All @@ -117,8 +113,7 @@ export default [
'type': 'circle',
'filter': ['all',
['==', 'meta', 'vertex'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
['==', '$type', 'Point']
],
'paint': {
'circle-radius': 3,
Expand All @@ -131,8 +126,7 @@ export default [
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Point'],
['==', 'meta', 'feature'],
['!=', 'mode', 'static']
['==', 'meta', 'feature']
],
'paint': {
'circle-radius': 5,
Expand All @@ -146,8 +140,7 @@ export default [
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Point'],
['==', 'meta', 'feature'],
['!=', 'mode', 'static']
['==', 'meta', 'feature']
],
'paint': {
'circle-radius': 3,
Expand Down Expand Up @@ -178,50 +171,5 @@ export default [
'circle-radius': 5,
'circle-color': '#fbb03b'
}
},
{
'id': 'gl-draw-polygon-fill-static',
'type': 'fill',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']],
'paint': {
'fill-color': '#404040',
'fill-outline-color': '#404040',
'fill-opacity': 0.1
}
},
{
'id': 'gl-draw-polygon-stroke-static',
'type': 'line',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']],
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-color': '#404040',
'line-width': 2
}
},
{
'id': 'gl-draw-line-static',
'type': 'line',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'LineString']],
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-color': '#404040',
'line-width': 2
}
},
{
'id': 'gl-draw-point-static',
'type': 'circle',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Point']],
'paint': {
'circle-radius': 5,
'circle-color': '#404040'
}
}
];

0 comments on commit ec28524

Please sign in to comment.