1.3.0-beta.0 • Published 3 years ago

@wq/mapbox v1.3.0-beta.0

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

@wq/mapbox

@wq/mapbox

@wq/mapbox is a plugin for @wq/app that provides integration with Mapbox GL JS (for web) and the Mapbox Map SDK for Android and iOS. When used together with @wq/map, @wq/mapbox can leverage the wq configuration object to generate interactive maps for pages rendered via @wq/app. The generated maps can automatically download and display GeoJSON data rendered by wq.db's REST API or any third party service.

Installation

wq.app for PyPI

python3 -m venv venv      # create virtual env (if needed)
. venv/bin/activate       # activate virtual env
python3 -m pip install wq # install wq framework (wq.app, wq.db, etc.)
# pip install wq.app      # install wq.app only

@wq/mapbox for npm

npm install @wq/mapbox # install @wq/mapbox, @wq/map, and deps

API

@wq/mapbox should be registered with @wq/app as a plugin. @wq/map will be registered automatically.

import app from '@wq/app';
import mapbox from '@wq/mapbox';

app.use(mapbox);  // Automatically registers @wq/map

app.init(...);

@wq/mapbox consists entirely of React components that override the placeholders defined in @wq/map. The components in @wq/mapbox are abstractions over existing libraries for each environment supported by @wq/react and @wq/material. Specifically, @wq/mapbox uses:

@wq/mapbox provides a consistent API in each of the three environments.

Configuration

@wq/mapbox relies on @wq/map's configuration and conventions. If config.map.mapProps is defined, it will be passed on as-is to the ReactMapboxGl() constructor for web and to the MapView component in Expo. For React Native, the accessToken, dragRotate, and pitchWithRotate mapProps are converted to the corresponding @react-native-mapbox-gl/maps arguments, and other props are ignored.

Components

@wq/mapbox provides implementations of the components defined by @wq/map.

plugin keydescription
componentsHigh-level map components (Map, Legend, etc.)
basemapsBasemap layers, typically tiled imagery or road network
overlaysOverlay layers, such as GeoJSON vectors

General Components

See @wq/map's general components for more info.

namedetails
Map (.native/.expo)Top level component that renders ReactMapboxGl() (web), MapboxGl.MapView (react native), or MapView (Expo).
LegendCurrently an empty wrapper
BasemapToggleCurrently an empty wrapper
OverlayToggleCurrently an empty wrapper
MapInteractionreact-mapbox-gl's <ZoomControl/>, <RotationControl/>, and <ScaleControl/> (web only)

Basemap Components

See @wq/map's basemap components for more info. Note that @wq/mapbox maps the concept of a basemap to Mapbox's map-level "style" prop. As such, the provided Tile and VectorTile components are empty except for Tile.expo.js. (react-native-maps does not support vector tiles.)

config namecomponentdetails
tileTile (.native/.expo)Raster tile layer, typically with 256x256 tile images in "Web Mercator" projection
vector-tileVectorTile (.native)Vector tile layer (web & react native only)

Overlay Components

See @wq/map's overlay components for more info. @wq/mapbox also provides tile and vector-tile overlays that can be added and removed from the map without resetting the style (unlike the basemaps).

config namecomponentdetails
geojsonGeojson (.native/.expo)GeoJSON overlay. If a URL is provided it will be retrieved and loaded
tileTile (.native/.expo)Raster tile overlay
vector-tileVectorTile (.native)Vector tile overlay
n/aHighlight (.native/.expo)GeoJSON overlay with preset highlight styles, which renders the contents (if any) of useMapState().highlight
n/aDrawDrawing tools based on react-mapbox-gl-draw (web only)