Skip to content

Commit e621086

Browse files
author
Andy Townsend
committed
Created separate debug and non-debug svwd01 index files.
1 parent 450b807 commit e621086

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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:50px; 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+
<div id="rest" style="font-size:100%; padding: 8px">
20+
<button id="button1" onclick="show_about();" >about</button>
21+
<button id="button2" onclick="show_schema_changelog();" >schema</button>
22+
<button id="button3" onclick="show_style_changelog();" >style</button>
23+
<button id="button4" onclick="show_mkgmap();" >mkgmap</button>
24+
<button id="button5" onclick="show_raster();" >raster</button>
25+
<button id="button5" onclick="show_osm();" >OSM</button>
26+
<button id="button5" onclick="show_whatpub();" >Camra pubs</button>
27+
<button id="button5" onclick="show_bustimes();" >Bus</button>
28+
</div>
29+
<div id='map'></div>
30+
<!-- <div id='refresh' onclick='reload()'>Reload</div> -->
31+
<script>
32+
var map;
33+
var osmAttrib='Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>';
34+
35+
/* -------------------------------------------------------------------------
36+
* Obtain the currect vector zoom level and location.
37+
* Add 1 to the vector zoom level to get the equivalent raster zoom level
38+
* Browse to the current location on the raster map.
39+
* Raster zooms are whole numbers, so any fractional part of the vector
40+
* zoom level is trunctated.
41+
* ------------------------------------------------------------------------- */
42+
function show_raster()
43+
{
44+
let zoom = map.getZoom() + 1;
45+
let {lng, lat} = map.getCenter();
46+
window.open ( '../maps/map/map.html'+'#'+zoom+'/'+lat+'/'+lng,'_self',false )
47+
}
48+
49+
function show_osm()
50+
{
51+
let zoom = map.getZoom() + 1;
52+
let {lng, lat} = map.getCenter();
53+
window.open ( 'https://osm.org/#map='+zoom+'/'+lat+'/'+lng,'_self',false )
54+
}
55+
56+
function show_whatpub()
57+
{
58+
let {lng, lat} = map.getCenter();
59+
window.open ( 'https://camra.org.uk/pubs/location/'+lat+'/'+lng+'?sort=nearest&hide_closed=false&venue_types[0]=P', '_blank' )
60+
}
61+
62+
function show_bustimes()
63+
{
64+
let zoom = map.getZoom();
65+
66+
if ( zoom > 18 )
67+
{
68+
zoom = 18;
69+
}
70+
71+
let {lng, lat} = map.getCenter();
72+
window.open ( 'https://bustimes.org/map#'+zoom+'/'+lat+'/'+lng,false )
73+
}
74+
75+
/* -------------------------------------------------------------------------
76+
* A button to display an about screen.
77+
* ------------------------------------------------------------------------- */
78+
function show_about()
79+
{
80+
window.open ( '../maps/map/vector.html','_self',false )
81+
}
82+
83+
function show_schema_changelog()
84+
{
85+
window.open ( '../maps/map/changelog_sve01.html','_self',false )
86+
}
87+
88+
function show_style_changelog()
89+
{
90+
window.open ( '../maps/map/changelog_svwd01.html','_self',false )
91+
}
92+
93+
function show_mkgmap()
94+
{
95+
window.open ( '../maps/map/mkgmap.html','_self',false )
96+
}
97+
98+
fetch("/metadata")
99+
.then(response => response.json())
100+
.then(data => {
101+
var styleURL = window.location.protocol+'//'+window.location.host+'/style.json';
102+
var bounds = data['bounds'].split(',');
103+
map = new maplibregl.Map({
104+
container: 'map', // container id
105+
style: styleURL, // stylesheet location
106+
center: [(Number(bounds[0])+Number(bounds[2]))/2,
107+
(Number(bounds[1])+Number(bounds[3]))/2], // starting position [lng, lat]
108+
hash: true,
109+
zoom: 13, // starting zoom
110+
maxZoom: 25,
111+
attributionControl: false
112+
});
113+
114+
// Add default OSM attribution
115+
map.addControl(new maplibregl.AttributionControl({ customAttribution: osmAttrib }), 'bottom-right');
116+
117+
// Add zoom control
118+
map.addControl(new maplibregl.NavigationControl());
119+
120+
map.dragRotate.disable();
121+
map.keyboard.disableRotation();
122+
map.touchZoomRotate.disableRotation();
123+
124+
// Add geolocate control
125+
map.addControl(
126+
new maplibregl.GeolocateControl({
127+
positionOptions: { enableHighAccuracy: true },
128+
trackUserLocation: true
129+
})
130+
);
131+
132+
// Add scale control at bottom-left
133+
map.addControl(
134+
new maplibregl.ScaleControl({
135+
unit: 'metric'
136+
})
137+
);
138+
139+
// -- Comment the following lines out to remove debug UI --
140+
// map.showTileBoundaries=true;
141+
142+
// map.addControl(new MaplibreInspect({
143+
// showInspectMap: true,
144+
// showInspectButton: false
145+
// }));
146+
147+
// -- --
148+
}
149+
)
150+
</script>
151+
152+
</body>
153+
</html>

0 commit comments

Comments
 (0)