| 1 | /*
|
|---|
| 2 |
|
|---|
| 3 | Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 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 |
|
|---|
| 22 | function openLink(target){
|
|---|
| 23 | window.location=target;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | function displayDataSet(data){
|
|---|
| 27 | $("#display #speedthroughwater #value").text(data["speedthroughwater"].toString());
|
|---|
| 28 | $("#display #speedoverground #value").text(data["speedoverground"].toString());
|
|---|
| 29 | $("#display #waterdepth #value").text(data["waterdepth"].toString());
|
|---|
| 30 | $("#display #watertemperature #value").text(Math.round(data["watertemperature"]).toString());
|
|---|
| 31 | $("#display #gps #value").text(data["gpsfix"]);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | function displayDataGet() {
|
|---|
| 35 | var gnuboatApi = "../webservice/";
|
|---|
| 36 | $.getJSON( gnuboatApi, displayDataSet);
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | function mapSetup(data){
|
|---|
| 40 | var overlay;
|
|---|
| 41 | var latitudeTop = data["bounds"][3];
|
|---|
| 42 | var latitudeBottom = data["bounds"][2];
|
|---|
| 43 | var longitudeLeft = data["bounds"][0];
|
|---|
| 44 | var longitudeRight = data["bounds"][1];
|
|---|
| 45 |
|
|---|
| 46 | var latitudeCenter = (latitudeTop - latitudeBottom)/2 + latitudeBottom;
|
|---|
| 47 | var longitudeCenter = (longitudeLeft - longitudeRight)/2 + longitudeRight;
|
|---|
| 48 |
|
|---|
| 49 | var mapBounds = new L.LatLngBounds(
|
|---|
| 50 | new L.LatLng(longitudeRight, latitudeTop),
|
|---|
| 51 | new L.LatLng(longitudeLeft, latitudeBottom));
|
|---|
| 52 | var mapMinZoom = data["minzoom"];
|
|---|
| 53 | var mapMaxZoom = data["maxzoom"];
|
|---|
| 54 | var map = L.map('map').setView([latitudeCenter,longitudeCenter], (mapMaxZoom - mapMinZoom)/2 + mapMinZoom);
|
|---|
| 55 |
|
|---|
| 56 | overlay = L.tileLayer('../webservice/tileserver.php?/index.json?/map/{z}/{x}/{y}.png', {
|
|---|
| 57 | minZoom: mapMinZoom, maxZoom: mapMaxZoom,
|
|---|
| 58 | bounds: mapBounds,
|
|---|
| 59 | attribution: 'undefined',opacity: 0.85
|
|---|
| 60 | }).addTo(map);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | $(document).ready(function() {
|
|---|
| 64 | displayDataGet();
|
|---|
| 65 | setInterval(displayDataGet, 5000);
|
|---|
| 66 |
|
|---|
| 67 | $.getJSON("../webservice/tileserver.php?/map.json", mapSetup);
|
|---|
| 68 | });
|
|---|