Improved www.ttss.krakow.pl
Jacek Kowalski
2019-07-05 19a3387f2cae0411e591070ba728eedacea2335b
Use CSS icon for geolocation button, wrap it in #menu
1 files renamed
2 files added
3 files modified
85 ■■■■■ changed files
icons/loc.svg 1 ●●●● patch | view | raw | blame | history
icons/pin.svg 1 ●●●● patch | view | raw | blame | history
icons/zoom.svg patch | view | raw | blame | history
map.css 58 ●●●●● patch | view | raw | blame | history
map.html 15 ●●●●● patch | view | raw | blame | history
map.js 10 ●●●● patch | view | raw | blame | history
icons/loc.svg
New file
@@ -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>
icons/pin.svg
New file
@@ -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>
icons/zoom.svg
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;
}
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>
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,