Browse Source

CategoryOverpass: get minZoom from query (if object)

master
parent
commit
e29f594c73
  1. 3
      README.md
  2. 10
      src/CategoryOverpass.js

3
README.md

@ -62,7 +62,6 @@ File: foo.json
"14": "(node[highway~'^(motorway_junction|mini_roundabout|crossing)$'];way[highway~'^(motorway|trunk|primary)$'];)",
"16": "(node[highway];way[highway];)"
}
"minZoom": 12,
"feature": {
"style": {
"color": "{% if tags.highway == 'motorway' %}#ff0000{% elseif tags.highway == 'trunk' %}#ff7f00{% elseif tags.highway == 'primary' %}#ffff00{% else %}#0000ff{% endif %}"
@ -82,7 +81,7 @@ This will define a category with the id 'foo' (from the file name). It will show
The following values are possible for categories (the only mandatory value is query):
* query: either a string or an object of strings with the minimal zoom level as index. Give the Overpass API queries without the header (e.g. `[out:json]` or bounding box) and footer (e.g. `out meta geom` or so).
* minZoom: Show layer only from the given zoom level (default: 14).
* minZoom: Show layer only from the given zoom level (default: 14). If `query` is an object and `minZoom` is not set, the lowest zoom level of a query will be used.
* maxZoom: Show layer only up to the given zoom level (default: no limit).
* feature: an object describing how the feature will be formated resp. styled.
* style: a Leaflet style.

10
src/CategoryOverpass.js

@ -3,7 +3,6 @@ var OverpassLayer = require('overpass-layer')
var OverpassLayerList = require('overpass-layer').List
var CategoryBase = require('./CategoryBase')
var defaultValues = {
minZoom: 14,
feature: {
title: "{{ localizedTag(tags, 'name') |default(localizedTag(tags, 'operator')) | default(localizedTag(tags, 'ref')) | default(trans('unnamed')) }}",
markerSign: "",
@ -46,6 +45,15 @@ function CategoryOverpass (id, data) {
}
}
// get minZoom
if ('minZoom' in data) {
// has minZoom
} else if (typeof data.query === 'object') {
data.minZoom = Object.keys(data.query)[0]
} else {
data.minZoom = 14
}
data.feature.appUrl = '#' + this.id + '/{{ id }}'
data.feature.body = (typeof data.feature.body === 'string' ? data.feature.body : '') + '<a class="showDetails" href="#' + this.id + '/{{ id }}/details">show details</a>'

Loading…
Cancel
Save