tileserver-gl/public/templates/viewer.tmpl
2023-01-26 18:29:04 -05:00

86 lines
2.8 KiB
Cheetah

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{name}} - TileServer GL</title>
<link rel="stylesheet" type="text/css" href="{{public_url}}maplibre-gl.css{{&key_query}}" />
<link rel="stylesheet" type="text/css" href="{{public_url}}maplibre-gl-inspect.css{{&key_query}}" />
<script src="{{public_url}}maplibre-gl.js{{&key_query}}"></script>
<script src="{{public_url}}maplibre-gl-inspect.min.js{{&key_query}}"></script>
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.leaflet-control-layers-toggle {
background-image: url({{public_url}}images/layers.png{{&key_query}});
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url({{public_url}}images/layers-2x.png{{&key_query}});
background-size: 26px 26px;
}
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
background-image: url({{public_url}}images/marker-icon.png{{&key_query}});
}
</style>
</head>
<body>
<h1 style="display:none;">{{name}}</h1>
<div id='map'></div>
<script>
const { searchParams } = new URL(document.location);
const accessKey = searchParams.get('key');
const keyParam = accessKey ? `?key=${accessKey}` : '';
var q = (location.search || '').substr(1).split('&');
var preference = q.indexOf('raster') >= 0 ? 'raster' : 'vector';
if (preference == 'vector') {
maplibregl.setRTLTextPlugin('{{public_url}}mapbox-gl-rtl-text.js' + keyParam);
var map = new maplibregl.Map({
container: 'map',
style: '{{public_url}}styles/{{id}}/style.json' + keyParam,
maplibreLogo: true,
hash: true
});
map.addControl(new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
}));
map.addControl(new MaplibreInspect({
showMapPopupOnHover: false,
showInspectMapPopupOnHover: false,
selectThreshold: 5
}));
} else {
var map = new maplibregl.Map({
container: 'map',
maplibreLogo: true,
hash: true,
style: {
version: 8,
sources: {
'RasterSource': {
type: 'raster',
url: '{{public_url}}styles/{{id}}.json' + keyParam
}
},
layers: [
{
id: 'RasterLayer',
type: 'raster',
source: 'RasterSource'
}
]
}
});
map.addControl(new maplibregl.NavigationControl({
visualizePitch: true,
showZoom: true,
showCompass: true
}));
}
</script>
</body>
</html>