0.1.6 • Published 2 years ago

@trailstash/map-view v0.1.6

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
2 years ago

TrailStash MapView

An opinionated configuration-driven map viewer powered by MapLibre GL JS.

A basic example comparing plain MapLibre GL JS usage and via TrailStash MapView:

// MapLibre GL JS
import maplibregl from "maplibre-gl.js";

const map = new maplibregl.Map({
  container: "map",
  style: "https://overpass-ultra.trailsta.sh/style.json",
  zoom: 4,
  center: [-100, 40],
  attributionControl: false,
});
map.addControl(new NavigationControl());
map.addControl(
  new GeolocateControl({
    positionOptions: {
      enableHighAccuracy: true,
    },
    trackUserLocation: true,
  }),
  "bottom-right",
);

// TrailStash MapView
import MapView from "@trailstash/map-view";
const mapView = new MapView({
  map: {
    container: "map",
    style: "https://overpass-ultra.trailsta.sh/style.json",
    zoom: 4,
    center: [-100, 40],
    attributionControl: false,
  },
  controls: [
    { type: "NavigationControl" },
    {
      position: "bottom-right",
      type: "GeolocateControl",
      options: {
        positionOptions: {
          enableHighAccuracy: true,
        },
        trackUserLocation: true,
      },
    },
  ],
});

In early stages of development and derived from OpenBikeHero.

Hosted

There is a hosted version of the viewer at https://trailstash.gitlab.io/map-view/

It can load JS or JSON configs passed to the config search parameter.

EG: https://trailstash.gitlab.io/map-view/?config=./configs/minimal.js

Configs:

linkpathdescriptionworks on hosted version
http://localhost:8000/?config=./configs/dev.js./configs/dev.jsA few controls & OSM OpenMapTiles style using Americana tile server(only works locally):x:
https://trailstash.gitlab.io/map-view/?config=./configs/minimal.js./configs/minimal.jsa minimal examle that loads OSM Carto raster tiles:heavy_check_mark:
https://trailstash.gitlab.io/map-view/?config=./configs/demo.json./configs/demo.jsonThe default configuration used at https://trailstash.gitlab.io/map-view/:heavy_check_mark:
https://trailstash.gitlab.io/map-view/?config=./configs/opentrailstash.js./configs/opentrailstash.jsIdentical to https://open.trailsta.sh except for the lack of the Overpass Ultra button:heavy_check_mark:
https://trailstash.gitlab.io/map-view/?config=https://trailstash.gitlab.io/openstyle-v2/mapview-config.jshttps://trailstash.gitlab.io/openstyle-v2/mapview-config.jsThe OpenTrailStash v2 prototype:heavy_check_mark:
0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago