From a8a6d131d09411b44e6ea8aea8cf798c6c62b1f8 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Tue, 18 Dec 2018 23:31:16 +0000 Subject: [PATCH] Update OpenLayers to version 5.3.0 --- map.js | 13 +++++++------ map.html | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/map.html b/map.html index c3f8c79..5eec3b6 100644 --- a/map.html +++ b/map.html @@ -4,7 +4,7 @@ <title>TTSS Kraków - Mapa</title> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" /> -<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css" /> +<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" type="text/css" /> </head> <body> @@ -15,7 +15,7 @@ <div id="popup"></div> <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList"></script> -<script src="https://openlayers.org/en/v4.6.5/build/ol.js" integrity="sha384-207r7vJ98mMvHGcgRttnhkJLl6RU+DuD+ttp1G5k4ShCtw03LfZIIDNNWDGU8m2F" crossorigin="anonymous"></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" id="lang_script"></script> <script tyle="text/javascript" src="common.js"></script> <script tyle="text/javascript" src="map.js"></script> diff --git a/map.js b/map.js index 16510c2..ff7bd0b 100644 --- a/map.js +++ b/map.js @@ -1,6 +1,7 @@ //var ttss_base = 'http://www.ttss.krakow.pl/internetservice'; var ttss_base = 'proxy.php'; var ttss_refresh = 10000; // 10 seconds +var ttss_position_type = 'CORRECTED'; var vehicles_xhr = null; var vehicles_timer = null; @@ -24,7 +25,6 @@ var route_layer = null; var map = null; -var map_sphere = null; var popup_element = document.getElementById('popup'); var popup_close_callback; var fail_element = document.getElementById('fail'); @@ -88,7 +88,7 @@ return new ol.style.Style({ image: new ol.style.Icon({ src: 'data:image/svg+xml;base64,' + btoa(image), - rotation: Math.PI * parseFloat(vehicle.get('heading')) / 180.0, + rotation: Math.PI * parseFloat(vehicle.get('heading') ? vehicle.get('heading') : 0) / 180.0, }), text: new ol.style.Text({ font: 'bold 10px sans-serif', @@ -158,7 +158,7 @@ vehicles_xhr = $.get( ttss_base + '/geoserviceDispatcher/services/vehicleinfo/vehicles' - + '?positionType=CORRECTED' + + '?positionType=' + ttss_position_type + '&colorType=ROUTE_BASED' + '&lastUpdate=' + encodeURIComponent(vehicles_last_update) ).done(function(data) { @@ -196,7 +196,7 @@ vehicles_source.addFeature(vehicle_feature); } else { vehicle_feature.setProperties(vehicle); - vehicle_feature.getStyle().getImage().setRotation(Math.PI * parseFloat(vehicle.heading) / 180.0); + vehicle_feature.getStyle().getImage().setRotation(Math.PI * parseFloat(vehicle.heading ? vehicle.heading : 0) / 180.0); } } @@ -536,6 +536,8 @@ stopId = window.location.hash.substr(3); } else if(window.location.hash.match(/^#!p-?[0-9]+$/)) { stopPointId = window.location.hash.substr(3); + } else if(window.location.hash == '#!RAW') { + ttss_position_type = 'RAW'; } if(tramId) { @@ -563,7 +565,7 @@ var c1 = ol.proj.transform(c1, 'EPSG:3857', 'EPSG:4326'); var c2 = ol.proj.transform(c2, 'EPSG:3857', 'EPSG:4326'); - return map_sphere.haversineDistance(c1, c2); + return ol.sphere.getDistance(c1, c2); } function returnClosest(point, f1, f2) { @@ -645,7 +647,6 @@ ]), loadTilesWhileAnimating: true, }); - map_sphere = new ol.Sphere(6378137); // Display popup on click map.on('singleclick', function(e) { -- Gitblit v1.9.1