
* add terrain preview and elevation link * add elevation api for terrain tiles * add documentation for elevation api * applied lint:js:fix * Add `test-docker` for test execution in docker build environment * Fix too greedy router expression * Add pmtile support Co-authored-by: Andrew Calcutt <acalcutt@techidiots.net> * add encoding param to pmtile section * add map controls Co-authored-by: Andrew Calcutt <acalcutt@techidiots.net> * remove not needed check * fix possible float usage in thumbnail url * update readme for encoding option * add better link name --------- Co-authored-by: Miko <miko@none> Co-authored-by: Andrew Calcutt <acalcutt@techidiots.net>
212 lines
6.5 KiB
Cheetah
212 lines
6.5 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>
|
|
{{#use_maplibre}}
|
|
<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.js{{&key_query}}"></script>
|
|
<style>
|
|
body {background:#fff;color:#333;font-family:Arial, sans-serif;}
|
|
{{^is_terrain}}
|
|
#map {position:absolute;top:0;left:0;right:250px;bottom:0;}
|
|
{{/is_terrain}}
|
|
{{#is_terrain}}
|
|
#map { position:absolute; top:0; bottom:0; width:100%; }
|
|
{{/is_terrain}}
|
|
h1 {position:absolute;top:5px;right:0;width:240px;margin:0;line-height:20px;font-size:20px;}
|
|
#layerList {position:absolute;top:35px;right:0;bottom:0;width:240px;overflow:auto;}
|
|
#layerList div div {width:15px;height:15px;display:inline-block;}
|
|
</style>
|
|
{{/use_maplibre}}
|
|
{{^use_maplibre}}
|
|
<link rel="stylesheet" type="text/css" href="{{public_url}}leaflet.css{{&key_query}}" />
|
|
<script src="{{public_url}}leaflet.js{{&key_query}}"></script>
|
|
<script src="{{public_url}}leaflet-hash.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>
|
|
{{/use_maplibre}}
|
|
</head>
|
|
<body>
|
|
{{#use_maplibre}}
|
|
<h1>{{name}}</h1>
|
|
<div id="map"></div>
|
|
{{^is_terrain}}
|
|
<div id="layerList"></div>
|
|
<pre id="propertyList"></pre>
|
|
{{/is_terrain}}
|
|
<script>
|
|
var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
|
|
var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
|
|
|
|
{{^is_terrain}}
|
|
var style = {
|
|
version: 8,
|
|
sources: {
|
|
'vector_layer_': {
|
|
type: 'vector',
|
|
url: '{{public_url}}data/{{id}}.json' + keyParam
|
|
}
|
|
},
|
|
layers: []
|
|
};
|
|
{{/is_terrain}}
|
|
{{#is_terrain}}
|
|
var style = {
|
|
version: 8,
|
|
sources: {
|
|
"terrain": {
|
|
"type": "raster-dem",
|
|
"url": "{{public_url}}data/{{id}}.json",
|
|
"encoding": "{{terrain_encoding}}"
|
|
},
|
|
"hillshade": {
|
|
"type": "raster-dem",
|
|
"url": "{{public_url}}data/{{id}}.json",
|
|
"encoding": "{{terrain_encoding}}"
|
|
}
|
|
},
|
|
"terrain": {
|
|
"source": "terrain"
|
|
},
|
|
layers: [
|
|
{
|
|
"id": "background",
|
|
"paint": {
|
|
{{^if is_terrainrgb}}
|
|
"background-color": "hsl(190, 99%, 63%)"
|
|
{{else}}
|
|
"background-color": "hsl(0, 100%, 25%)"
|
|
{{/if}}
|
|
},
|
|
"type": "background"
|
|
},
|
|
{
|
|
"id": "hillshade",
|
|
"source": "hillshade",
|
|
"type": "hillshade",
|
|
"paint": {
|
|
"hillshade-shadow-color": "hsl(39, 21%, 33%)",
|
|
"hillshade-illumination-direction": 315,
|
|
"hillshade-exaggeration": 0.8
|
|
}
|
|
}
|
|
]
|
|
};
|
|
{{/is_terrain}}
|
|
|
|
var map = new maplibregl.Map({
|
|
container: 'map',
|
|
hash: true,
|
|
maxPitch: 85,
|
|
style: style
|
|
});
|
|
map.addControl(new maplibregl.NavigationControl({
|
|
visualizePitch: true,
|
|
showZoom: true,
|
|
showCompass: true
|
|
}));
|
|
{{#is_terrain}}
|
|
map.addControl(
|
|
new maplibregl.TerrainControl({
|
|
source: "terrain",
|
|
})
|
|
);
|
|
{{/is_terrain}}
|
|
{{^is_terrain}}
|
|
var inspect = new MaplibreInspect({
|
|
showInspectMap: true,
|
|
showInspectButton: false
|
|
});
|
|
map.addControl(inspect);
|
|
map.on('styledata', function() {
|
|
var layerList = document.getElementById('layerList');
|
|
layerList.innerHTML = '';
|
|
Object.keys(inspect.sources).forEach(function(sourceId) {
|
|
var layerIds = inspect.sources[sourceId];
|
|
layerIds.forEach(function(layerId) {
|
|
var item = document.createElement('div');
|
|
item.innerHTML = '<div style="' +
|
|
'background:' + inspect.assignLayerColor(layerId) + ';' +
|
|
'"></div> ' + layerId;
|
|
layerList.appendChild(item);
|
|
});
|
|
})
|
|
});
|
|
{{/is_terrain}}
|
|
</script>
|
|
{{/use_maplibre}}
|
|
{{^use_maplibre}}
|
|
<h1 style="display:none;">{{name}}</h1>
|
|
<div id='map'></div>
|
|
<script>
|
|
var keyMatch = location.search.match(/[\?\&]key=([^&]+)/i);
|
|
var keyParam = keyMatch ? '?key=' + keyMatch[1] : '';
|
|
var map = L.map('map', { zoomControl: false });
|
|
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
|
|
|
var tile_urls = [], tile_attribution, tile_minzoom, tile_maxzoom;
|
|
var url = '{{public_url}}data/{{id}}.json' + keyParam;
|
|
var req = new XMLHttpRequest();
|
|
req.overrideMimeType("application/json");
|
|
req.open('GET', url, true);
|
|
req.onload = function() {
|
|
var jsonResponse = JSON.parse(req.responseText);
|
|
for (key in jsonResponse) {
|
|
var keyl = key.toLowerCase();
|
|
switch(keyl) {
|
|
case "tiles":
|
|
tile_urls = jsonResponse[key];
|
|
break;
|
|
case "attribution":
|
|
tile_attribution = jsonResponse[key];
|
|
break;
|
|
case "minzoom":
|
|
tile_minzoom = jsonResponse[key];
|
|
break;
|
|
case "maxzoom":
|
|
tile_maxzoom = jsonResponse[key];
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (tile_url in tile_urls) {
|
|
L.tileLayer(tile_urls[tile_url], {
|
|
tileSize: 256,
|
|
minZoom: tile_minzoom,
|
|
maxZoom: tile_maxzoom,
|
|
attribution: tile_attribution
|
|
}).addTo(map);
|
|
}
|
|
|
|
map.eachLayer(function(layer) {
|
|
// do not add scale prefix even if retina display is detected
|
|
layer.scalePrefix = '.';
|
|
});
|
|
};
|
|
req.send(null);
|
|
|
|
setTimeout(function() {
|
|
new L.Hash(map);
|
|
}, 0);
|
|
</script>
|
|
{{/use_maplibre}}
|
|
</body>
|
|
</html>
|