Skip to content

A simple Node-Express server to view geojson and mbtiles in mapboxgl

Notifications You must be signed in to change notification settings

meracan/mapbox-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mapboxgl-express

A simple Node-Express server to view geojson and mbtiles in mapboxgl

Installation

The package is currently not on npm. For local installation:

git clone git@github.com:meracan/mapbox-express.git
npm install

Usage

Running server

Needs to specify one environment variable DATAFOLDER.

Using npm and package descriptor: Example

npm start

Using node directly:

DATAFOLDER='../data' node server.js

To view the web application: http://localhost:8080

Mapbox token

Mapbox requires an unique TOKEN. Token can be generated using a free account on Mapbox.

Mapbox geoJSON and MBTiles

Data/Source (.geojson and .mbtiles) can be added to mapbox.js. The link is data/{relativePathtfromDATAFOLDER} for geoJSON. The link is tiles/{relativePathtfromDATAFOLDER} for mbtiles. For more information on source

Example:

map.addSource('exampleG', {'type': 'geojson','data': url+"/data/example.geojson"});
map.addSource('exampleT', {'type': 'vector','tiles': [url+"/tiles/example/{z}/{x}/{y}.pbf"]});

Mapbox Layers

Layers are the style applied to the source. For more information on layer Example:

map.addLayer({'id': 'circle','type': 'circle','source': 'exampleG','paint':{'circle-radius':3,'circle-color': 'red','circle-opacity': 0.8}});
map.addLayer({'id': 'line','type': 'line','source': 'exampleT','source-layer': 'example','layout': {'line-cap': 'round','line-join': 'round'},'paint': {'line-opacity': 0.6,'line-color': 'rgb(0, 0, 0)','line-width': 2}},);
map.addLayer({'id': 'fill','type': 'fill','source': 'exampleT','source-layer': 'example','paint': {'fill-color': '#088','fill-opacity': 0.8});

About

A simple Node-Express server to view geojson and mbtiles in mapboxgl

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published