aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/assets/map.html
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/assets/map.html')
-rw-r--r--src/main/assets/map.html52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/main/assets/map.html b/src/main/assets/map.html
index da45d9ad9..5e9370270 100644
--- a/src/main/assets/map.html
+++ b/src/main/assets/map.html
@@ -13,15 +13,16 @@
</head>
<body>
-
<style>
#map{width:100%;height:100%;position:fixed;top:0px;left:0px;right:0px;bottom:0px}
</style>
- <div id='map'>
- </div>
+ <div id='map'></div>
<script type="text/javascript">
+ var marker;
+
+ //get location from URL
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
@@ -30,24 +31,33 @@
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') {
+ // create map
+ if (getUrlParameter('lat') != null && getUrlParameter('lon') != null) {
var map = L.map('map', {
zoomControl: true,
- attributionControl: false
- }).fitWorld();
- } else {
+ attributionControl: true
+ }).setView([getUrlParameter('lat'), getUrlParameter('lon')], 15);
+ // add marker
+ if (!marker) {
+ marker = L.marker([getUrlParameter('lat'), getUrlParameter('lon')]).addTo(map);
+ marker.bindPopup((getUrlParameter('name')), {
+ closeOnClick: false,
+ closeButton: false,
+ autoClose: false
+ }).openPopup();
+ }
+ } else {
var map = L.map('map', {
zoomControl: true,
attributionControl: true
- }).setView([getUrlParameter('lat'), getUrlParameter('lon')], 15);
+ }).fitWorld();
}
map.addLayer(new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
@@ -55,16 +65,20 @@
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);
+ // Change view to coordinates
+ function toCoordinates(latIntent, lonIntent, Name){
+ map.setView([parseFloat(latIntent), parseFloat(lonIntent)], 15);
+ if (!marker) {
+ marker = L.marker([parseFloat(latIntent), parseFloat(lonIntent)]).addTo(map);
+ marker.bindPopup(("..."), {
+ closeOnClick: false,
+ closeButton: false,
+ autoClose: false
+ }).openPopup();
+ }
+ marker.setLatLng([parseFloat(latIntent), parseFloat(lonIntent)]).update();
+ marker.setPopupContent(Name);
}
</script>
- </body>
+ </body>
</html> \ No newline at end of file