source: src/webapp/webclient/javascript/main.js@ e62038b

0.5 app-cordova debian/bullseye debian/jessie
Last change on this file since e62038b was e62038b, checked in by Joachim Langenbach <joachim.langenbach@…>, 10 years ago

Added construction plans and therefore restructered the folder structure

Signed-off-by: Joachim Langenbach <joachim.langenbach@…>

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[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
22function openLink(target){
23 window.location=target;
24}
25
26function displayDataSet(data){
[3121b3b]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"]);
[d7e6e9c]32}
33
34function displayDataGet() {
[6f38643]35 var gnuboatApi = "../webservice/";
[d7e6e9c]36 $.getJSON( gnuboatApi, displayDataSet);
37}
38
[6f38643]39function 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
[d7e6e9c]63$(document).ready(function() {
64 displayDataGet();
65 setInterval(displayDataGet, 5000);
[6f38643]66
67 $.getJSON("../webservice/tileserver.php?/map.json", mapSetup);
[d7e6e9c]68});
Note: See TracBrowser for help on using the repository browser.