Leaflet GeoJSON

From Maps for MediaWiki

Maps supports working with GeoJSON since version 6.

Since GeoJSON is an open standard, many tools allow you to create and consume GeoJson. A simple online visual map editor that outputs GeoJSON is geojson.io.

In-wiki GeoJSON

Since version 6.0, you can store your GeoJSON in wiki pages in the GeoJson namespace. For instance GeoJson:Berlin. You can use this GeoJSON via the geojson parameter by giving it the page name. The GeoJSON stored in a page can be used by as many maps as you like.

{{#display_map: center=Berlin | geojson=Berlin}}
Loading map...

Make sure the pages in the GeoJson namespace contain valid JSON. Once saved, the pages show a preview of the GeoJSON on a Leaflet map.

Visual editor

Since version 6.7, the pages in the GeoJson namespace contain a visual map editor. The editor is only shown to those with permission to edit the page.

Since version 7.13 the editor is also shown on regular maps that use GeoJson. Since version 14.1 this requires the map to use a single GeoJson page: the editor replaces the whole page it was opened on, so no edit button is shown on a map that combines several sources.

Semantic MediaWiki integration

Since Maps version 7.16, experimental SMW integration stores GeoJson data as SubObjects. Contact Jeroen De Dauw for more information.

GeoJSON export

You can export GeoJSON stored on a GeoJSON page by clicking "edit" or "view source" and copying the content.

Alternatively, add ?action=raw to the page URL. Example: GeoJson:Berlin?action=raw

Limitations

As of version 14.1:

  • Only Leaflet supports GeoJson
  • Marker icons cannot be replaced, though the marker color can be set with the marker-color property since version 12.1
  • Images and links cannot be added to the markers
  • No visual editing of shape styles
  • Editing the GeoJSON page directly does not cause automatic updates on pages that make use of it
  • No captcha integration: edits will fail for users who need to fill out a captcha to edit
  • The preview maps on GeoJson pages cannot be customized via wikitext or configuration

You can hire Jeroen De Dauw (creator of Maps) to work on the above via Professional Wiki.

GeoJSON files

{{#display_map: center=Berlin
 | geojson = https://raw.githubusercontent.com/leakyMirror/map-of-europe/master/GeoJSON/europe.geojson
}}
Loading map...

Several sources on one map

Since version 14.1, the geojson parameter takes a list of pages and file URLs separated by semicolons. All of them are shown on the same map, so each dataset can stay on its own page and be combined where needed.

{{#display_map: center=Berlin | zoom=9 | geojson=Berlin;BerlinLandmarks}}
Loading map...

This shows the city outline from GeoJson:Berlin together with the points from GeoJson:BerlinLandmarks. Pages and file URLs can be mixed in one list.

Sources that cannot be found are skipped, so the remaining ones still show. A page name or URL that itself contains a semicolon cannot be used, since the semicolon separates the list.

See also