aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/assets/map.html
blob: da45d9ad9008cb9cbe05f89d51fc37d838460273 (plain)
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
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link href="font-awesome.min.css" rel="stylesheet">
		<link href="animate.min.css" rel="stylesheet">

		<script src="jquery.min.js"></script>
		<link rel="stylesheet" href="leaflet.css"/>
		<script src="leaflet.js"></script>
	</head>

	<body>

		<style>
			#map{width:100%;height:100%;position:fixed;top:0px;left:0px;right:0px;bottom:0px}
		</style>

		<div id='map'>
		</div>

		<script type="text/javascript">
			var getUrlParameter = function getUrlParameter(sParam) {
				var sPageURL = decodeURIComponent(window.location.search.substring(1)),
				sURLVariables = sPageURL.split('&'),
				sParameterName,
				i;

				for (i = 0; i < sURLVariables.length; i++) {
					sParameterName = sURLVariables[i].split('=');

					if (sParameterName[0] === sParam) {
						return sParameterName[1] === undefined ? true : sParameterName[1];
					}
				}
			};

			if (typeof getUrlParameter('lat') === 'undefined' && typeof getUrlParameter('lon') === 'undefined') {
				var map = L.map('map', {
					zoomControl: true,
					attributionControl: false
				}).fitWorld();
			} else {

				var map = L.map('map', {
					zoomControl: true,
					attributionControl: true
				}).setView([getUrlParameter('lat'), getUrlParameter('lon')], 15);
			}

			map.addLayer(new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
				minZoom: 1,
				maxZoom: 19
			}));

			if (typeof getUrlParameter('lat') !== 'undefined' && typeof getUrlParameter('lon') !== 'undefined' && typeof getUrlParameter('name') !== 'undefined') {
				var marker = L.marker([getUrlParameter('lat'), getUrlParameter('lon')]).addTo(map);
				marker.bindPopup(getUrlParameter('name'), {
					closeOnClick: false,
					closeButton: false,
					autoClose: false
				}).openPopup();
			} else if (typeof getUrlParameter('lat') !== 'undefined' && typeof getUrlParameter('lon') !== 'undefined' && typeof getUrlParameter('name') === 'undefined') {
				var marker = L.marker([getUrlParameter('lat'), getUrlParameter('lon')]).addTo(map);
			}
		</script>
    </body>
</html>