You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Stephan Bösch-Plepelits 043a331c47 Update submodules ; modulekit-lang follows master branch 7 years ago
bin categories-to-lang: not translated -> add empty string (instead of null) 7 years ago
dist Make sure the dist/ directory is always created 7 years ago
doc Docu: improve icons documentation 7 years ago
img manifest.json: add file 7 years ago
lang Update pt-br 7 years ago
lib/modulekit Update submodules ; modulekit-lang follows master branch 7 years ago
modulekit@8c875354b7 Update submodules ; modulekit-lang follows master branch 7 years ago
src tagTranslations: function isTranslated (also as twig function) 7 years ago
.gitignore Update .gitignore and install instructions 7 years ago
.gitmodules Update submodules ; modulekit-lang follows master branch 7 years ago
README.md At end of initialization call hook 'initFinish' 7 years ago
ajax.php ajax.php: pass all get parameters to functions 7 years ago
asset.php asset.php: when param list is supplied, return list of files 7 years ago
composer.json Instead of FreeGeoIP use local GeoIP database 7 years ago
conf.php-dist Make 'en' the default language in config 7 years ago
httpGet.php httpGet: fallback to load-via-server; option 'forceServerLoad' 7 years ago
index.php Add a measurement control 7 years ago
manifest.json manifest.json: add file 7 years ago
modulekit.php Repository: split common code to RepositoryBase 7 years ago
package.json CategoryOverpass: adapt to overpass-layer v1.0.1 7 years ago
repo.php repo.php/addCategories: repositoryUrl and categoryUrl 7 years ago
style.css Popup Footer: use a list for links 7 years ago

README.md

INSTALL

git clone https://github.com/plepe/openstreetbrowser.git
cd openstreetbrowser
npm install
composer install
git submodule init
git submodule update
cp conf.php-dist conf.php
nano conf.php
npm run build
modulekit/build_cache
bin/download_dependencies

=> more detailed Installation instructions

Upgrade

cd openstreetbrowser
git pull
npm update
git submodule init
git submodule update
npm run build

DEVELOPMENT

Develop categories

rm -r node_modules/openstreetbrowser-categories-main
git clone https://github.com/plepe/openstreetbrowser-categories-main.git node_modules/openstreetbrowser-categories-main

You are welcome to send pull requests via Github!

Category definition

There are currently two types of categories: index (for sub categories) and overpass (for OpenStreetMap data, loaded via an Overpass API request). Each of them is defined via a JSON structure. They can be combined into a single file.

Category 'index'

File: dir.json

{
    "type": "index",
    "subCategories": [
        {
            "id": "foo"
        },
        {
            "id": "bar",
            "type": "overpass",
            "query": "node[amenity=bar]"
        }
    ]
}

This will define a category with the id 'dir' (from the file name) with two sub-categories: 'foo' (which will be loaded from the file foo.json) and 'bar' (which is defined inline as category of type 'overpass' and will show all nodes with the tag 'amenity' set to value 'bar' - see below for more details).

Category 'overpass'

File: foo.json

{
    "type": "overpass",
    "query": {
        "12": "(node[highway~'^(motorway_junction)$'];way[highway~'^(motorway|trunk)$'];)",
        "14": "(node[highway~'^(motorway_junction|mini_roundabout|crossing)$'];way[highway~'^(motorway|trunk|primary)$'];)",
        "16": "(node[highway];way[highway];)"
    }
    "feature": {
        "style": {
            "color": "{% if tags.highway == 'motorway' %}#ff0000{% elseif tags.highway == 'trunk' %}#ff7f00{% elseif tags.highway == 'primary' %}#ffff00{% else %}#0000ff{% endif %}"
        },
        "markerSign": "{% if tags.highway == 'motorway_junction' %}↗{% elseif tags.highway == 'mini_roundabout' %}↻{% elseif tags.highway == 'crossing' %}▤{% endif %}",
        "title": "{{ localizedTag(tags, 'name') |default(localizedTag(tags, 'operator')) | default(localizedTag(tags, 'ref')) | default(trans('unnamed')) }}",
        "description": "{{ tagTrans('highway', tags.highway) }}",
        "body": "Foo value: {{ const.foo }}"
    },
    "const": {
        "foo": "foo value"
    }
}

This will define a category with the id 'foo' (from the file name). It will show some highway amenities, depending on the current zoom level.

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). 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.
      • stroke: Whether to draw stroke along the path. Set it to false or empty string to disable borders on polygons or circles. (boolean, true)
      • width: Stroke width in pixels (number, 3)
      • color: Stroke color (string, '#3388ff')
      • opacity: Stroke opacity (number, 1.0)
      • lineCap: shape at end of the stroke (string, 'round')
      • lineJoin: shape at corners of the stroke (string, 'round')
      • dashArray: stroke dash pattern (string, null)
      • dashOffset: distrance into the dash pattern to start dash (string, null)
      • fill: whether to fill the path with color. Set it to false or empty string to disable filling on polygons or circles. (boolean, depends)
      • fillColor: Fill color. Defaults to the value of the color option. (string)
      • fillOpacity: Fill opacity. (number, 0.2)
      • fillRule: define how the inside of a shape is determined. (string, 'evenodd')
      • smoothFactor: (unclosed ways only) How much to simplify the polyline on each zoom level. (number, 1.0)
      • noClip: (unclosed ways only) Disable polyline clipping. (boolean, false)
      • nodeFeature: (nodes only) Which type of feature to show on nodes. Valid values: 'Marker', 'Circle', 'CircleMarker'. (string, 'CircleMarker')
      • radius: (nodes with nodeFeature 'Circle' or 'CircleMarker' only) Radius of the circle (for 'Circle': in meters, for 'CircleMarker': in pixels, default: 10). (number)
    • title: the title of the feature popup, the object in the list and the details page. (default: localized tags for 'name', 'operator' or 'ref', default: 'unknown')
    • body: the body for the feature popup and the details page.
    • description: a short description shown in the list next to the title.
    • popupDescription: like description, but an alternative if the description in popups should be different from the list.
    • markerSign: a HTML string which will be shown within the marker and in the list. (default: '')
    • priority: a numeric value by which the elements in the list will be sorted (lower values first)
    • preferredZoom: At which max. zoom level will the map zoom when showing details
  • const: an object variable which is available as prefix in twig functions.

All values in the "feature" section may use the TwigJS language for evaluation.

Hooks

With the function register_hook you can hook into several functions. The following hooks are available:

  • state-get: modules can add values into the current state. Parameters: state: an object, which can be modified by modules.
  • state-apply: when a state is applied to the app. Parameters: state: state which should be applied.
  • show-details: called when details are being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback.
  • hide-details: called when the details page is left. No parameters.
  • show-popup: called when a popup is being displayed. Parameters: data (see properties in doc/TwigJS.md), category, dom, callback.
  • options_save: called when options are saved. Parameters: options (the new object), old_options (before save)
  • initFinish: called when the app initialization finishes