-
Notifications
You must be signed in to change notification settings - Fork 6
/
embed.html
91 lines (76 loc) · 2.96 KB
/
embed.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<html>
<head>
<title>OpenStreetMap.by - embeddable map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.10.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.10.0/mapbox-gl.css" rel="stylesheet" />
<script src="/static/js/openmaptiles-language.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
var mmap;
var auto_layer;
var auto_active=true;
var json_in_progress = false;
</script>
</head>
<body marginheight="0" marginwidth="0">
<div id="map" style="width: 100%; height: 100%; padding:0; spacing:0"></div>
<script><!--
params = {};
var idx = window.location.href.indexOf('?');
if (idx >= 0) {
params = window.location.href.slice(idx + 1).split('&');
for(var i = 0; i < params.length; i++) {
var tmp = decodeURIComponent((params[i] + '').replace(/\+/g, '%20')).split('=');
params[tmp[0]] = tmp[1];
}
}
// parsing, adding defaults
params.lat = parseFloat(params.lat) || 53.9142;
params.lon = parseFloat(params.lon) || 27.5955;
params.zoom = parseFloat(params.zoom) || 11;
params.lang = params.lang || 'be'; // TODO: autodetect browser
params.crosshair = params.crosshair || false;
params.marker = params.marker=='true';
params.mlat = parseFloat(params.mlat) || params.lat;
params.mlon = parseFloat(params.mlon) || params.lon;
params.markertext = params.markertext || '';
params.zoomcontrol= !(params.zoomcontrol=='false');
// fixing
if ((params.lang != 'en') &&
(params.lang != 'ru') &&
(params.lang != 'be') &&
(params.lang != 'be:word_stress'') &&
(params.lang != 'be-tarask') &&
(params.lang != 'be-tarask:word_stress') &&
(params.lang != 'be-latn') &&
(params.lang != 'be-latn:word_stress'))
params.lang = 'be';
mmap = new mapboxgl.Map({
container: 'map',
style: 'styles/bright/style.json',
center: [params.lon, params.lat], //lng lat
zoom: params.zoom
});
if (params.lang === 'en') {
mmap.setLanguage(params.lang, false);
} else {
mmap.setLanguage(params.lang, true);
}
if (params.marker){
var markerEl = document.createElement('div');
markerEl.className = 'marker';
markerEl.style.backgroundImage = 'url(https://unpkg.com/[email protected]/dist/images/marker-icon.png)';
markerEl.style.width = 25;
markerEl.style.height = 41;
var marker = new mapboxgl.Marker(markerEl, {offset:[-12, -20]})
.setLngLat([params.mlon, params.mlat]);
if (params.markertext != ''){
var popup = new mapboxgl.Popup({offset:[0, -20]}).setText(params.markertext);
marker.setPopup(popup);
}
marker.addTo(mmap);
}
//--></script>
</body>
</html>