diff --git a/API.md b/API.md index 9263c1831..dda44dd4e 100644 --- a/API.md +++ b/API.md @@ -20,6 +20,10 @@ in the hash portion of the URL: `{z}`/`{zoom}`, `{ty}` for flipped TMS-style Y coordinates, and `{switch:a,b,c}` for DNS multiplexing.
_Example:_ `background=custom:https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png` +* __`disable_features`__ - Disables features in the list.
+ _Example:_ `disable_features=water,service_roads,points,paths,boundaries`
+ _Available features:_ `points` `traffic_roads` `service_roads` `paths` `buildings` `landuse` + `boundaries` `water` `rail` `power` `past_future` `others` * __`gpx`__ - A custom URL for loading a gpx track. Specifying a `gpx` parameter will automatically enable the gpx layer for display.
_Example:_ `gpx=https://tasks.hotosm.org/project/592/task/16.gpx` @@ -34,10 +38,6 @@ in the hash portion of the URL: _Example:_ `hashtags=%23hotosm-task-592,%23MissingMaps` * __`rtl=true`__ - Force iD into right-to-left mode (useful for testing). * __`walkthrough=true`__ - Start the walkthrough automatically -* __`features`__ - Enables features in the list.
- _Example:_ `features=water,service_roads,points,paths`
- _Available features:_ `points` `traffic_roads` `service_roads` `paths` `buildings` `landuse` - `boundaries` `water` `rail` `power` `past_future` `others` ##### iD on openstreetmap.org (Rails Port) @@ -49,12 +49,12 @@ are available as regular URL query parameters: * __`lat`__, __`lon`__, __`zoom`__ - Self-explanatory. * __`node`__, __`way`__, __`relation`__ - Select the specified entity. * __`background`__ - same as standalone +* __`disable_features`__ - same as standalone * __`gpx`__ - same as standalone * __`offset`__ - same as standalone * __`comment`__ - same as standalone * __`hashtags`__ - same as standalone * __`walkthrough`__ - same as standalone -* __`features`__ - same as standalone ## CSS selectors diff --git a/modules/core/context.js b/modules/core/context.js index 8bdc08bc1..28ec30f60 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -471,6 +471,7 @@ export function coreContext() { }); background.init(); + features.init(); presets.init(); areaKeys = presets.areaKeys(); diff --git a/modules/renderer/features.js b/modules/renderer/features.js index 23f58b94c..47dcd3091 100644 --- a/modules/renderer/features.js +++ b/modules/renderer/features.js @@ -3,7 +3,6 @@ import _groupBy from 'lodash-es/groupBy'; import _reduce from 'lodash-es/reduce'; import _some from 'lodash-es/some'; import _union from 'lodash-es/union'; -import _get from 'lodash-es/get'; import { dispatch as d3_dispatch } from 'd3-dispatch'; @@ -65,16 +64,13 @@ export function rendererFeatures(context) { _features = {}, _stats = {}, _keys = [], - _hidden = [], - _initFeaturesStr = _get(utilStringQs(window.location.hash.substring(1)), 'features', '').trim(); + _hidden = []; function update() { - var q = utilStringQs(window.location.hash.substring(1)); - - q.features = context.features().enabledList(); - if (!window.mocha) { + var q = utilStringQs(window.location.hash.substring(1)); + q.disable_features = features.disabled().join(','); window.location.replace('#' + utilQsString(q, true)); } @@ -87,10 +83,6 @@ export function rendererFeatures(context) { function defineFeature(k, filter, max) { var isEnabled = true; - if (_initFeaturesStr.length) { - isEnabled = _initFeaturesStr.split(',').some(function(key){ return key === k; }); - } - _keys.push(k); _features[k] = { filter: filter, @@ -506,5 +498,14 @@ export function rendererFeatures(context) { }; + features.init = function() { + var q = utilStringQs(window.location.hash.substring(1)); + if (q.disable_features) { + q.disable_features.replace(/;/g, ',').split(',').map(function(k) { + features.disable(k); + }); + } + }; + return utilRebind(features, dispatch, 'on'); }