|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset='utf-8' /> |
| 5 | + <title>SPEC_NAME</title> |
| 6 | + <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> |
| 7 | + <script src=' https://unpkg.com/[email protected]/dist/maplibre-gl.js' ></script> |
| 8 | + <link href=' https://unpkg.com/[email protected]/dist/maplibre-gl.css' rel=' stylesheet' /> |
| 9 | + <script src='https://unpkg.com/@maplibre/maplibre-gl-inspect@latest/dist/maplibre-gl-inspect.js'></script> |
| 10 | + <link href='https://unpkg.com/@maplibre/maplibre-gl-inspect@latest/dist/maplibre-gl-inspect.css' rel='stylesheet' /> |
| 11 | + <style> |
| 12 | + body { margin:0; padding:0; } |
| 13 | + #map { position:absolute; top:0; bottom:0; width:100%; } |
| 14 | + #refresh { position: absolute; top: 15px; left: 15px; background-color: white; padding: 5px; |
| 15 | + border: 1px solid black; font-family: Avenir; cursor: pointer; } |
| 16 | + </style> |
| 17 | +</head> |
| 18 | +<body> |
| 19 | + |
| 20 | +<div id='map'></div> |
| 21 | +<!-- <div id='refresh' onclick='reload()'>Reload</div> --> |
| 22 | +<script> |
| 23 | +var map; |
| 24 | +var osmAttrib='Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'; |
| 25 | + |
| 26 | +fetch("/metadata") |
| 27 | + .then(response => response.json()) |
| 28 | + .then(data => { |
| 29 | + var styleURL = window.location.protocol+'//'+window.location.host+'/style.json'; |
| 30 | + var bounds = data['bounds'].split(','); |
| 31 | + |
| 32 | +// Currently RTL support isn't native in MapLibre GL, but a MapBox plugin does support it. |
| 33 | +// See https://maplibre.org/maplibre-gl-js/docs/examples/mapbox-gl-rtl-text/ |
| 34 | + maplibregl.setRTLTextPlugin( |
| 35 | + 'https://unpkg.com/@mapbox/[email protected]/dist/mapbox-gl-rtl-text.js', |
| 36 | + true // Lazy load the plugin |
| 37 | + ); |
| 38 | + |
| 39 | + map = new maplibregl.Map({ |
| 40 | + container: 'map', // container id |
| 41 | + style: styleURL, // stylesheet location |
| 42 | + center: [ -1.5, 53 ], // starting position [lng, lat] |
| 43 | + hash: true, |
| 44 | + zoom: 8, // starting zoom |
| 45 | + maxZoom: 25, |
| 46 | + attributionControl: true |
| 47 | + }); |
| 48 | + |
| 49 | + map.on('style.load', () => { |
| 50 | + map.setProjection({ |
| 51 | + type: 'globe', // Set projection to globe |
| 52 | + }); |
| 53 | + }); |
| 54 | + |
| 55 | +// Add default OSM attribution |
| 56 | +// map.addControl(new maplibregl.AttributionControl({ customAttribution: osmAttrib }), 'bottom-right'); |
| 57 | + |
| 58 | + // Add zoom control |
| 59 | + map.addControl(new maplibregl.NavigationControl()); |
| 60 | + |
| 61 | + map.dragRotate.disable(); |
| 62 | + map.keyboard.disableRotation(); |
| 63 | + map.touchZoomRotate.disableRotation(); |
| 64 | + |
| 65 | + // Add geolocate control |
| 66 | + map.addControl( |
| 67 | + new maplibregl.GeolocateControl({ |
| 68 | + positionOptions: { enableHighAccuracy: true }, |
| 69 | + trackUserLocation: true |
| 70 | + }) |
| 71 | + ); |
| 72 | + |
| 73 | + // Add scale control at bottom-left |
| 74 | + map.addControl( |
| 75 | + new maplibregl.ScaleControl({ |
| 76 | + unit: 'metric' |
| 77 | + }) |
| 78 | + ); |
| 79 | + |
| 80 | + // -- Comment the following lines out to remove debug UI -- |
| 81 | + map.showTileBoundaries=false; |
| 82 | + |
| 83 | +// map.addControl(new MaplibreInspect({ |
| 84 | +// showInspectMap: true, |
| 85 | +// showInspectButton: false |
| 86 | +// })); |
| 87 | + |
| 88 | + // -- -- |
| 89 | + } |
| 90 | +) |
| 91 | +</script> |
| 92 | + |
| 93 | +</body> |
| 94 | +</html> |
0 commit comments