mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 19:01:08 +00:00
Inspector improvements (#218)
* conditionally reposition map if map hash wasn't passed [#49] * add 20230408 basemap to viewer presets
This commit is contained in:
@@ -9,6 +9,10 @@ import "maplibre-gl/dist/maplibre-gl.css";
|
|||||||
import { schemeSet3 } from "d3-scale-chromatic";
|
import { schemeSet3 } from "d3-scale-chromatic";
|
||||||
import base_theme from "protomaps-themes-base";
|
import base_theme from "protomaps-themes-base";
|
||||||
|
|
||||||
|
const INITIAL_ZOOM = 0;
|
||||||
|
const INITIAL_LNG = 0;
|
||||||
|
const INITIAL_LAT = 0;
|
||||||
|
|
||||||
maplibregl.setRTLTextPlugin(
|
maplibregl.setRTLTextPlugin(
|
||||||
"https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js",
|
"https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js",
|
||||||
() => {},
|
() => {},
|
||||||
@@ -367,8 +371,8 @@ function MaplibreMap(props: { file: PMTiles }) {
|
|||||||
const map = new maplibregl.Map({
|
const map = new maplibregl.Map({
|
||||||
container: mapContainerRef.current!,
|
container: mapContainerRef.current!,
|
||||||
hash: "map",
|
hash: "map",
|
||||||
zoom: 0,
|
zoom: INITIAL_ZOOM,
|
||||||
center: [0, 0],
|
center: [INITIAL_LNG, INITIAL_LAT],
|
||||||
style: {
|
style: {
|
||||||
version: 8,
|
version: 8,
|
||||||
sources: {},
|
sources: {},
|
||||||
@@ -433,7 +437,12 @@ function MaplibreMap(props: { file: PMTiles }) {
|
|||||||
if (mapRef.current) {
|
if (mapRef.current) {
|
||||||
let map = mapRef.current;
|
let map = mapRef.current;
|
||||||
let header = await props.file.getHeader();
|
let header = await props.file.getHeader();
|
||||||
|
if (
|
||||||
|
map.getCenter().lng === INITIAL_LNG &&
|
||||||
|
map.getCenter().lat == INITIAL_LAT &&
|
||||||
|
map.getZoom() === INITIAL_ZOOM
|
||||||
|
) {
|
||||||
|
// the map hash was not passed, so auto-detect the initial viewport based on metadata
|
||||||
map.fitBounds(
|
map.fitBounds(
|
||||||
[
|
[
|
||||||
[header.minLon, header.minLat],
|
[header.minLon, header.minLat],
|
||||||
@@ -441,6 +450,7 @@ function MaplibreMap(props: { file: PMTiles }) {
|
|||||||
],
|
],
|
||||||
{ animate: false }
|
{ animate: false }
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let style: any; // TODO maplibre types (not any)
|
let style: any; // TODO maplibre types (not any)
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ const ExampleList = styled("div", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const EXAMPLE_FILES = [
|
const EXAMPLE_FILES = [
|
||||||
|
"https://r2-public.protomaps.com/protomaps-sample-datasets/protomaps-basemap-opensource-20230408.pmtiles",
|
||||||
"https://protomaps.github.io/PMTiles/protomaps(vector)ODbL_firenze.pmtiles",
|
"https://protomaps.github.io/PMTiles/protomaps(vector)ODbL_firenze.pmtiles",
|
||||||
"https://protomaps.github.io/PMTiles/stamen_toner(raster)CC-BY+ODbL_z3.pmtiles",
|
"https://protomaps.github.io/PMTiles/stamen_toner(raster)CC-BY+ODbL_z3.pmtiles",
|
||||||
"https://r2-public.protomaps.com/protomaps-sample-datasets/cb_2018_us_zcta510_500k.pmtiles",
|
"https://r2-public.protomaps.com/protomaps-sample-datasets/cb_2018_us_zcta510_500k.pmtiles",
|
||||||
|
|||||||
Reference in New Issue
Block a user