From 19a3387f2cae0411e591070ba728eedacea2335b Mon Sep 17 00:00:00 2001
From: Jacek Kowalski <Jacek@jacekk.info>
Date: Fri, 05 Jul 2019 22:27:13 +0000
Subject: [PATCH] Use CSS icon for geolocation button, wrap it in #menu
---
map.js | 10 ++--
icons/loc.svg | 1
map.html | 15 ++-----
icons/zoom.svg | 2
icons/pin.svg | 1
map.css | 58 ++++++++++++++++++++---------
6 files changed, 53 insertions(+), 34 deletions(-)
diff --git a/icons/loc.svg b/icons/loc.svg
new file mode 100644
index 0000000..3b6c3f9
--- /dev/null
+++ b/icons/loc.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><style>*{stroke:black;stroke-width:5;fill:none}</style><circle cx="40" cy="40" r="25"></circle><circle cx="40" cy="40" r="10" style="fill:black;"></circle><line x1="40" y1="15" x2="40" y2="0"></line><line x1="65" y1="40" x2="80" y2="40"></line><line x1="40" y1="65" x2="40" y2="80"></line><line x1="15" y1="40" x2="0" y2="40"></line></svg>
\ No newline at end of file
diff --git a/icons/pin.svg b/icons/pin.svg
new file mode 100644
index 0000000..0959679
--- /dev/null
+++ b/icons/pin.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M32,64L14.1855,29.0909A20,20 0 1 1 49.8145,29.0909ZM42,20A10,10 0 0 0 22,20A10,10 0 0 0 42,20"/></svg>
\ No newline at end of file
diff --git a/zoom.svg b/icons/zoom.svg
similarity index 99%
rename from zoom.svg
rename to icons/zoom.svg
index c26f046..2ab24f7 100644
--- a/zoom.svg
+++ b/icons/zoom.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="490" height="490"><path fill="none" stroke="#000" stroke-width="36" stroke-linecap="round" d="m280,278a153,153 0 1,0-2,2l170,170m-91-117 110,110-26,26-110-110"/></svg>
+<svg xmlns="http://www.w3.org/2000/svg" width="490" height="490"><path fill="none" stroke="#000" stroke-width="36" stroke-linecap="round" d="m280,278a153,153 0 1,0-2,2l170,170m-91-117 110,110-26,26-110-110"/></svg>
\ No newline at end of file
diff --git a/map.css b/map.css
index 2f499d9..938f5e7 100644
--- a/map.css
+++ b/map.css
@@ -135,25 +135,44 @@
float: right;
}
-.pad-left-icon {
+.addon-icon {
margin-left: 0.2rem;
}
-.icon-zoom {
+.normal-icon, .addon-icon {
+ font-size: 1rem;
+}
+.icon, .icon-loc, .icon-pin, .icon-zoom {
display: inline-block;
- height: 1rem;
- width: 1rem;
+ height: 1em;
+ width: 1em;
text-indent: 1rem;
overflow: hidden;
- background-image: url(zoom.svg);
- background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OTAiIGhlaWdodD0iNDkwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMzYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgZD0ibTI4MCwyNzhhMTUzLDE1MyAwIDEsMC0yLDJsMTcwLDE3MG0tOTEtMTE3IDExMCwxMTAtMjYsMjYtMTEwLTExMCIvPjwvc3ZnPgo=);
background-size: contain;
background-repeat: no-repeat;
+}
+.reverse {
+ filter: invert(100%);
+}
+.icon-loc {
+ background-image: url(icons/loc.svg);
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4MCIgaGVpZ2h0PSI4MCI+PHN0eWxlPip7c3Ryb2tlOmJsYWNrO3N0cm9rZS13aWR0aDo1O2ZpbGw6bm9uZX08L3N0eWxlPjxjaXJjbGUgY3g9IjQwIiBjeT0iNDAiIHI9IjI1Ij48L2NpcmNsZT48Y2lyY2xlIGN4PSI0MCIgY3k9IjQwIiByPSIxMCIgc3R5bGU9ImZpbGw6YmxhY2s7Ij48L2NpcmNsZT48bGluZSB4MT0iNDAiIHkxPSIxNSIgeDI9IjQwIiB5Mj0iMCI+PC9saW5lPjxsaW5lIHgxPSI2NSIgeTE9IjQwIiB4Mj0iODAiIHkyPSI0MCI+PC9saW5lPjxsaW5lIHgxPSI0MCIgeTE9IjY1IiB4Mj0iNDAiIHkyPSI4MCI+PC9saW5lPjxsaW5lIHgxPSIxNSIgeTE9IjQwIiB4Mj0iMCIgeTI9IjQwIj48L2xpbmU+PC9zdmc+);
+}
+.icon-pin {
+ background-image: url(icons/pin.svg);
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCI+PHBhdGggZD0iTTMyLDY0TDE0LjE4NTUsMjkuMDkwOUEyMCwyMCAwIDEgMSA0OS44MTQ1LDI5LjA5MDlaTTQyLDIwQTEwLDEwIDAgMCAwIDIyLDIwQTEwLDEwIDAgMCAwIDQyLDIwIi8+PC9zdmc+);
+}
+.icon-zoom {
+ background-image: url(icons/zoom.svg);
+ background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0OTAiIGhlaWdodD0iNDkwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMzYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgZD0ibTI4MCwyNzhhMTUzLDE1MyAwIDEsMC0yLDJsMTcwLDE3MG0tOTEtMTE3IDExMCwxMTAtMjYsMjYtMTEwLTExMCIvPjwvc3ZnPgo=);
}
#title {
top: .5em;
left: .5em;
- padding: 2px .5em;
+ padding: 0 .5em;
+ font-size: 1.14em;
+ line-height: 1.4em;
+ height: 1.375em;
font-weight: bold;
background-color: rgba(255,255,255,.6);
}
@@ -169,24 +188,27 @@
right: 0.5em;
}
.ol-zoom {
- top: 2.2em;
+ top: 2.3em;
}
-#track {
+#menu {
top: 6em;
left: 0.5em;
}
-.ol-touch #track {
+.ol-touch #menu {
top: 7em;
}
+#menu button {
+ border-radius: 0;
+}
+#menu button:first-child {
+ border-top-left-radius: 2px;
+ border-top-right-radius: 2px;
+}
+#menu button:last-child {
+ border-bottom-left-radius: 2px;
+ border-bottom-right-radius: 2px;
+}
-.ol-control button svg * {
- stroke: white;
- stroke-width: 5%;
- fill: none;
-}
-.ol-control button svg .fill {
- fill: white;
-}
.ol-control button.clicked {
background-color: black;
}
diff --git a/map.html b/map.html
index 8545a78..be0d733 100644
--- a/map.html
+++ b/map.html
@@ -5,27 +5,22 @@
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v5.3.0/css/ol.css" integrity="sha384-C7SzZySesoxngSK5V0BaD1DUap0LPZGWZpnXQGoIwvBXFc8G21y4s1QYvyr84FNa" crossorigin="anonymous">
-<link rel="stylesheet" href="map.css?v4" type="text/css" />
+<link rel="stylesheet" href="map.css?v5" type="text/css" />
<link rel="manifest" href="map.manifest" />
</head>
<body>
<div id="map">
<div id="title" class="ol-unselectable ol-control"><a href="/">TTSS Kraków</a></div>
-<div id="track" class="ol-unselectable ol-control"><button type="button" title="GPS"><svg width="100%" height="100%">
-<circle cx="50%" cy="50%" r="25%"></circle>
-<circle cx="50%" cy="50%" r="10%" class="fill"></circle>
-<line x1="50%" y1="25%" x2="50%" y2="10%"></line>
-<line x1="75%" y1="50%" x2="90%" y2="50%"></line>
-<line x1="50%" y1="75%" x2="50%" y2="90%"></line>
-<line x1="25%" y1="50%" x2="10%" y2="50%"></line>
-</svg></button></div>
<div id="fail" class="ol-unselectable ol-control"><span></span> <span class="close">×</p></div>
+<div id="menu" class="ol-unselectable ol-control">
+<button id="track" type="button" title="GPS"><span class="icon-loc reverse"></span></button>
+</div>
</div>
<div id="panel"></div>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.prototype.forEach,Array.prototype.includes,Array.prototype.map,Element.prototype.classList,Promise,String.prototype.startsWith,XMLHttpRequest,requestAnimationFrame"></script>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v5.3.0/build/ol.js" integrity="sha384-iQkGyyH4ioz3m+maM3s9MX1Oq67mACa4B9Z3ovUv3Sv37LJ96fx3WnZfLoiC3Wfl" crossorigin="anonymous"></script>
<script tyle="text/javascript" src="lang_pl.js?v9" id="lang_script"></script>
<script tyle="text/javascript" src="common.js?v10"></script>
-<script tyle="text/javascript" src="map.js?v23"></script>
+<script tyle="text/javascript" src="map.js?v24"></script>
</body>
</html>
diff --git a/map.js b/map.js
index 1bbd8c2..07f2361 100644
--- a/map.js
+++ b/map.js
@@ -594,7 +594,7 @@
})}, 10);
};
showOnMapElement.addEventListener('click', showOnMapFunction);
- showOnMapElement.className = 'icon-zoom pad-left-icon';
+ showOnMapElement.className = 'icon-pin addon-icon';
showOnMapElement.title = lang.show_on_map;
if(additional) {
@@ -839,9 +839,9 @@
geolocation_layer = new ol.layer.Vector({
source: geolocation_source,
});
- geolocation_button = document.querySelector('#track button');
+ geolocation_button = document.querySelector('#track');
if(!navigator.geolocation) {
- geolocation_button.classList.add('hidden');
+ geolocation_button.remove();
}
geolocation = new ol.Geolocation({projection: 'EPSG:3857'});
@@ -866,7 +866,7 @@
geolocation.on('error', function(error) {
fail(lang.error_location + ' ' + error.message);
trackingStop();
- geolocation_button.classList.add('hidden');
+ geolocation_button.remove();
});
geolocation_button.addEventListener('click', trackingToggle);
@@ -904,7 +904,7 @@
element: fail_element,
}),
new ol.control.Control({
- element: document.getElementById('track'),
+ element: document.getElementById('menu'),
}),
]),
loadTilesWhileAnimating: false,
--
Gitblit v1.9.1