Skip to content

A Mapbox plugin to enable multi-floors maps

Notifications You must be signed in to change notification settings

hteco/mapbox-gl-indoor

 
 

Repository files navigation

Mapbox GL Indoor Plugin

A mapboxgl-js plugin to enable multi-floors maps

Note: This is a work in progress and we welcome contributions.

Demo

https://indoor.thibaud-michel.com/caserne

Usage

Create an OSM indoor map following the Simple Indoor Tagging guidelines.

Transform the osm file into a geojson using osmtogeojson.

Then use the following code:

// Create the indoor handler
const indoor = new Indoor(map);

// Retrieve the geojson from the path and add the map
fetch('maps/gare-de-l-est.geojson')
    .then(res => res.json())
    .then(geojson => {
        indoor.addMap(IndoorMap.fromGeojson(geojson));
    });

// Add the specific control
map.addControl(new IndoorControl(indoor));

Options

For the moment, refer to samples.

How does it work?

The library parses the geojson to find level tags and retrieve the map range (minimum and maximum levels).

If the viewport of the map intersects the building bounds, then the map is selected and the IndoorControl is visible.

When a level is set (initialisation or user click), only the geojson features which have the level property equals (or in the range of) to the current level are shown.

Developing

npm install & npm start

Visit http://localhost:9966/ to load the samples

With docker-compose

Install and start: docker-compose up --build

About

A Mapbox plugin to enable multi-floors maps

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.2%
  • Dockerfile 2.8%