From 8c9a527fdf9a54699a596e0a6579cc95fb9b4314 Mon Sep 17 00:00:00 2001 From: bfabiszewski Date: Fri, 21 Jun 2013 11:15:09 +0200 Subject: OpenLayers API --- api_gmaps.js | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100755 api_gmaps.js (limited to 'api_gmaps.js') diff --git a/api_gmaps.js b/api_gmaps.js new file mode 100755 index 0000000..d4132ce --- /dev/null +++ b/api_gmaps.js @@ -0,0 +1,173 @@ +/* phpTrackme + * + * Copyright(C) 2013 Bartek Fabiszewski (www.fabiszewski.net) + * + * This is free software; you can redistribute it and/or modify it under + * the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +// google maps +var map; +var polies = new Array(); +var markers = new Array(); +var popups = new Array(); +var polyOptions; +var mapOptions; +var loadedAPI = 'gmaps'; +function init() { +google.maps.visualRefresh = true; + polyOptions = { + strokeColor: '#FF0000', + strokeOpacity: 1.0, + strokeWeight: 2 + } + mapOptions = { + center: new google.maps.LatLng(52.23, 21.01), + zoom: 8, + mapTypeId: google.maps.MapTypeId.ROADMAP, + scaleControl: true + }; + map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); +} + +function displayTrack(xml,update) { + altitudes.length = 0; + var totalMeters = 0; + var totalSeconds = 0; + // init polyline + var poly = new google.maps.Polyline(polyOptions); + poly.setMap(map); + var path = poly.getPath(); + var latlngbounds = new google.maps.LatLngBounds( ); + var positions = xml.getElementsByTagName('position'); + var posLen = positions.length; + for (var i=0; i'+lang_user+': '+p.username.toUpperCase()+'
'+lang_track+': '+p.trackname.toUpperCase()+ + ''+ + '
'+ + '
'+lang_time+': '+p.dateoccured+'
'+ + ((p.speed != null)?''+lang_speed+': '+(p.speed.toKmH()*factor_kmh)+' '+unit_kmh+'
':'')+ + ((p.altitude != null)?''+lang_altitude+': '+(p.altitude*factor_m).toFixed()+' '+unit_m+'
':'')+'
'+ + ((latest==0)? + ('
'+lang_ttime+': '+p.totalSeconds.toHMS()+'
'+ + ''+lang_aspeed+': '+((p.totalSeconds>0)?((p.totalMeters/p.totalSeconds).toKmH()*factor_kmh).toFixed():0)+' '+unit_kmh+'
'+ + ''+lang_tdistance+': '+(p.totalMeters.toKm()*factor_km).toFixed(2)+' '+unit_km+'
'+'
'):'')+ + '
'+lang_point+' '+(i+1)+' '+lang_of+' '+(posLen)+'
'+ + '
'; + popup = new google.maps.InfoWindow(); + popup.listener = google.maps.event.addListener(marker, 'click', (function(marker,content) { + return function() { + popup.setContent(content); + popup.open(map, marker); + if (document.getElementById('bottom').style.display=='block') { + chart.setSelection([{row:i,column:null}]); + } + } + })(marker,content)); + markers.push(marker); + popups.push(popup); +} + +function addChartEvent(chart) { + google.visualization.events.addListener(chart, 'select', function() { + if (popup) {popup.close(); clearTimeout(altTimeout);} + var selection = chart.getSelection()[0]; + if (selection) { + var id = selection.row; + var icon = markers[id].getIcon(); + markers[id].setIcon('http://maps.google.com/mapfiles/marker_orange.png'); + //var contentString = '
'+Math.round(altitudes[id]*factor_m)+' '+unit_m+'
'; + //popup = new google.maps.InfoWindow({ + // content: contentString + //}); + //popup.open(map,markers[id]); + //altTimeout = setTimeout(function() { if (popup) {popup.close();} },2000); + altTimeout = setTimeout(function() { markers[id].setIcon(icon); },2000); + } + }); +} -- cgit v1.2.3