| [d7e6e9c] | 1 | /*
|
|---|
| 2 |
|
|---|
| [3121b3b] | 3 | Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| [d7e6e9c] | 4 |
|
|---|
| 5 | This library is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This library is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Lesser General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 16 | License along with this library; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|---|
| 18 | MA 02110-1301 USA.
|
|---|
| 19 |
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| [f8dfbe7] | 22 | var map;
|
|---|
| 23 | var points = [];
|
|---|
| 24 | var polyline;
|
|---|
| 25 |
|
|---|
| [d7e6e9c] | 26 | function openLink(target){
|
|---|
| 27 | window.location=target;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | function displayDataSet(data){
|
|---|
| [3121b3b] | 31 | $("#display #speedthroughwater #value").text(data["speedthroughwater"].toString());
|
|---|
| 32 | $("#display #speedoverground #value").text(data["speedoverground"].toString());
|
|---|
| 33 | $("#display #waterdepth #value").text(data["waterdepth"].toString());
|
|---|
| 34 | $("#display #watertemperature #value").text(Math.round(data["watertemperature"]).toString());
|
|---|
| 35 | $("#display #gps #value").text(data["gpsfix"]);
|
|---|
| [f8dfbe7] | 36 |
|
|---|
| 37 | var latitude = data["latitude"];
|
|---|
| 38 | var longitude = data["longitude"];
|
|---|
| 39 | if(latitude && longitude){
|
|---|
| 40 | if(points.length > 0){
|
|---|
| 41 | var lastPoint = points[points.length - 1];
|
|---|
| 42 | if(lastPoint.lat != latitude || lastPoint.lng != longitude){
|
|---|
| 43 | points.push(new L.latLng(latitude, longitude));
|
|---|
| 44 | console.log(points);
|
|---|
| 45 | polyline.setLatLngs(points);
|
|---|
| 46 | map.fitBounds(polyline.getBounds());
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| [d7e6e9c] | 50 | }
|
|---|
| 51 |
|
|---|
| 52 | function displayDataGet() {
|
|---|
| [6f38643] | 53 | var gnuboatApi = "../webservice/";
|
|---|
| [d7e6e9c] | 54 | $.getJSON( gnuboatApi, displayDataSet);
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| [6f38643] | 57 | function mapSetup(data){
|
|---|
| 58 | var overlay;
|
|---|
| 59 | var latitudeTop = data["bounds"][3];
|
|---|
| [f8dfbe7] | 60 | var latitudeBottom = data["bounds"][1];
|
|---|
| [6f38643] | 61 | var longitudeLeft = data["bounds"][0];
|
|---|
| [f8dfbe7] | 62 | var longitudeRight = data["bounds"][2];
|
|---|
| 63 |
|
|---|
| 64 | var mapZoomMin = data["minzoom"];
|
|---|
| 65 | var mapZoomMax = data["maxzoom"];
|
|---|
| [6f38643] | 66 |
|
|---|
| 67 | var latitudeCenter = (latitudeTop - latitudeBottom)/2 + latitudeBottom;
|
|---|
| 68 | var longitudeCenter = (longitudeLeft - longitudeRight)/2 + longitudeRight;
|
|---|
| [f8dfbe7] | 69 | var mapZoomStart = (mapZoomMax - mapZoomMin)/2 + mapZoomMin;
|
|---|
| 70 |
|
|---|
| [6f38643] | 71 | var mapBounds = new L.LatLngBounds(
|
|---|
| [f8dfbe7] | 72 | new L.LatLng(latitudeBottom, longitudeLeft),
|
|---|
| 73 | new L.LatLng(latitudeTop, longitudeRight));
|
|---|
| 74 |
|
|---|
| 75 | map = L.map('map').setView([latitudeCenter, longitudeCenter], mapZoomStart);
|
|---|
| [6f38643] | 76 |
|
|---|
| 77 | overlay = L.tileLayer('../webservice/tileserver.php?/index.json?/map/{z}/{x}/{y}.png', {
|
|---|
| [f8dfbe7] | 78 | minZoom: mapZoomMin, maxZoom: mapZoomMax,
|
|---|
| [6f38643] | 79 | bounds: mapBounds,
|
|---|
| 80 | attribution: 'undefined',opacity: 0.85
|
|---|
| [f8dfbe7] | 81 | }).addTo(map);
|
|---|
| 82 |
|
|---|
| 83 | points.push(new L.latLng(47.5914051, 10.710862));
|
|---|
| 84 | points.push(new L.latLng(47.576667, 10.735278));
|
|---|
| 85 | polyline = L.polyline(points, {color: 'red'}).addTo(map);
|
|---|
| [6f38643] | 86 | }
|
|---|
| 87 |
|
|---|
| [d7e6e9c] | 88 | $(document).ready(function() {
|
|---|
| 89 | displayDataGet();
|
|---|
| 90 | setInterval(displayDataGet, 5000);
|
|---|
| [6f38643] | 91 |
|
|---|
| 92 | $.getJSON("../webservice/tileserver.php?/map.json", mapSetup);
|
|---|
| [d7e6e9c] | 93 | });
|
|---|