Changeset 2648146
- Timestamp:
- 12/23/2021 03:58:31 AM (4 years ago)
- Location:
- gps-plotter/trunk
- Files:
-
- 6 edited
-
gpsplotter.php (modified) (1 diff)
-
includes/class-gpsplotter-setup.php (modified) (3 diffs)
-
public/assets/js/gpsplotter-map.js (modified) (21 diffs)
-
public/assets/js/gpsplotter-openmap.js (modified) (18 diffs)
-
readme.txt (modified) (1 diff)
-
templates/shortcode-gpsplotter-map.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
gps-plotter/trunk/gpsplotter.php
r2570534 r2648146 4 4 Plugin URI: https://www.stpetedesign.com/gps-plotter/ 5 5 Description: Track Android phones in real time using a map displayed on your website. Upgrade to <a href="https://www.stpetedesign.com/product/gps-plotter-bootleg/">GPS Plotter BOOTLEG</a> our premium version with extra features. 6 Version: 5.1. 26 Version: 5.1.3 7 7 Author: Steve Curtis, St. Pete Design 8 8 Author URI: https://www.stpetedesign.com/gps-plotter/ -
gps-plotter/trunk/includes/class-gpsplotter-setup.php
r1857574 r2648146 99 99 $procedure_name = $wpdb->prefix . "get_routes"; 100 100 $wpdb->query( "DROP PROCEDURE IF EXISTS {$procedure_name};" ); 101 101 102 102 $sql = "CREATE PROCEDURE {$procedure_name}() 103 103 BEGIN 104 CREATE TEMPORARY TABLE temp_routes ( 104 105 CREATE TEMPORARY TABLE IF NOT EXISTS temp_routes ( 105 106 session_id VARCHAR(50), 106 107 user_name VARCHAR(50), … … 115 116 UPDATE temp_routes tr 116 117 SET start_time = (SELECT MIN(gps_time) FROM {$table_name} gl 117 WHERE gl.session_id = tr.session_id118 AND gl.user_name = tr.user_name);118 WHERE gl.session_id COLLATE utf8mb4_general_ci = tr.session_id COLLATE utf8mb4_general_ci 119 AND gl.user_name COLLATE utf8mb4_general_ci = tr.user_name COLLATE utf8mb4_general_ci ); 119 120 120 121 UPDATE temp_routes tr 121 122 SET end_time = (SELECT MAX(gps_time) FROM {$table_name} gl 122 WHERE gl.session_id = tr.session_id123 AND gl.user_name = tr.user_name);123 WHERE gl.session_id COLLATE utf8mb4_general_ci = tr.session_id COLLATE utf8mb4_general_ci 124 AND gl.user_name COLLATE utf8mb4_general_ci = tr.user_name COLLATE utf8mb4_general_ci ); 124 125 125 126 SELECT … … 144 145 CONCAT('{\"type\": \"Feature\", \"id\": \"', CAST(session_id AS CHAR), '\", \"properties\": {\"speed\": ', CAST(speed AS CHAR), ', \"direction\": ', CAST(direction AS CHAR), ', \"distance\": ', CAST(distance AS CHAR), ', \"location_method\": \"', CAST(location_method AS CHAR), '\", \"gps_time\": \"', DATE_FORMAT(gps_time, '%b %e %Y %h:%i%p'), '\", \"user_name\": \"', CAST(user_name AS CHAR), '\", \"phone_number\": \"', CAST(phone_number AS CHAR), '\", \"accuracy\": ', CAST(accuracy AS CHAR), ', \"geojson_counter\": ', @counter := @counter + 1, ', \"extra_info\": \"', CAST(extra_info AS CHAR), '\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [', CAST(longitude AS CHAR), ', ', CAST(latitude AS CHAR), ']}}') geojson 145 146 FROM {$table_name} 146 WHERE session_id = _session_id147 WHERE session_id COLLATE utf8mb4_general_ci = _session_id COLLATE utf8mb4_general_ci 147 148 ORDER BY last_update; 148 149 END;"; -
gps-plotter/trunk/public/assets/js/gpsplotter-map.js
r1857574 r2648146 1 jQuery(document).ready(function ($) {1 jQuery(document).ready(function ($) { 2 2 var pluginUrl = map_js_vars.plugin_url; 3 3 var selectRoute = document.getElementById('selectRoute'); 4 var map = document.getElementById('map-canvas'); 4 var map = document.getElementById('map-canvas'); 5 5 var intervalID = 0; 6 var zoom = 12; 6 var zoom = 12; 7 7 var autoRefresh = false; 8 8 var sessionIDArray = []; 9 9 var viewingAllRoutes = false; 10 11 var map_type = "ROADMAP";12 10 11 var map_type = "ROADMAP"; 12 13 13 /* demo response 14 14 var bws_demo = {"type": "FeatureCollection", "features": [{"type": "Feature", "id": "8BA21D90-3F90-407F-BAAE-800B04B1F5ED", "properties": {"speed": 0, "direction": 0, "distance": 0.0, "location_method": "na", "gps_time": "Jan 3 2007 11:43AM", "user_name": "wordpressUser1", "phone_number": "1BA21D90-3F90-407F-BAAE-800B04B1F5ED", "accuracy": 137, "geojson_counter": 1, "extra_info": "na"}, "geometry": {"type": "Point", "coordinates": [-122.2145580, 47.6366310]}},{"type": "Feature", "id": "8BA21D90-3F90-407F-BAAE-800B04B1F5ED", "properties": {"speed": 0, "direction": 0, "distance": 0.0, "location_method": "na", "gps_time": "Jan 3 2007 11:44AM", "user_name": "wordpressUser1", "phone_number": "1BA21D90-3F90-407F-BAAE-800B04B1F5ED", "accuracy": 137, "geojson_counter": 2, "extra_info": "na"}, "geometry": {"type": "Point", "coordinates": [-122.2017690, 47.6379610]}},{"type": "Feature", "id": "8BA21D90-3F90-407F-BAAE-800B04B1F5ED", "properties": {"speed": 0, "direction": 0, "distance": 0.0, "location_method": "na", "gps_time": "Jan 3 2007 11:45AM", "user_name": "wordpressUser1", "phone_number": "1BA21D90-3F90-407F-BAAE-800B04B1F5ED", "accuracy": 137, "geojson_counter": 3, "extra_info": "na"}, "geometry": {"type": "Point", "coordinates": [-122.2095790, 47.6429350]}}]}; 15 15 */ 16 16 17 17 18 18 getAllRoutesForMap(); 19 19 loadRoutesIntoDropdownBox(); 20 21 $("#viewall").click(function () {20 21 $("#viewall").click(function () { 22 22 getAllRoutesForMap(); 23 23 }); 24 25 $("#bws_satelite").click(function() {26 if(map_type == "ROADMAP"){27 map_type = "SATELLITE";28 $("#bws_satelite").html("Roadmap View");29 }else{30 map_type = "ROADMAP";31 $("#bws_satelite").html("Satellite View");32 }24 25 $("#bws_satelite").click(function () { 26 if (map_type == "ROADMAP") { 27 map_type = "SATELLITE"; 28 $("#bws_satelite").html("Roadmap View"); 29 } else { 30 map_type = "ROADMAP"; 31 $("#bws_satelite").html("Satellite View"); 32 } 33 33 34 34 if (viewingAllRoutes) { 35 getAllRoutesForMap(); 35 getAllRoutesForMap(); 36 36 } else { 37 37 if (hasMap()) { 38 38 getRouteForMap(); 39 } 40 } 41 }); 42 43 44 $('#selectRoute').on('change', function () {39 } 40 } 41 }); 42 43 44 $('#selectRoute').on('change', function () { 45 45 if (hasMap()) { 46 46 viewingAllRoutes = false; 47 47 48 48 getRouteForMap(); 49 } 50 }); 51 52 $('#autorefresh').click(function () {49 } 50 }); 51 52 $('#autorefresh').click(function () { 53 53 if (autoRefresh) { 54 turnOffAutoRefresh(); 55 } else { 56 turnOnAutoRefresh(); 57 } 58 }); 59 60 $("#delete").click(function () {54 turnOffAutoRefresh(); 55 } else { 56 turnOnAutoRefresh(); 57 } 58 }); 59 60 $("#delete").click(function () { 61 61 if (hasMap()) { 62 62 deleteRoute(); 63 } 64 }); 65 66 $("#refresh").click(function () {63 } 64 }); 65 66 $("#refresh").click(function () { 67 67 if (viewingAllRoutes) { 68 getAllRoutesForMap(); 68 getAllRoutesForMap(); 69 69 } else { 70 70 if (hasMap()) { 71 71 getRouteForMap(); 72 } 73 } 74 }); 75 72 } 73 } 74 }); 75 76 76 function setTheme() { 77 77 //var bodyBackgroundColor = $('body').css('backgroundColor'); … … 80 80 // $('head').append('<link rel="stylesheet" href="style2.css" type="text/css" />'); 81 81 } 82 82 83 83 function getAllRoutesForMap() { 84 84 // when the page first loads, get the routes from the DB and load them into the dropdown box. 85 85 86 86 viewingAllRoutes = true; 87 87 //selectRoute.selectedIndex = 0; 88 88 showPermanentMessage('Please select a route below'); 89 89 90 90 $.post( 91 map_js_vars.ajax_url,91 map_js_vars.ajax_url, 92 92 { 93 93 'action': 'get_all_geojson_routes', 94 94 'get_all_geojson_routes_nonce': map_js_vars.get_all_geojson_routes_nonce 95 95 }, 96 function (response) {97 /* Runing on demo data bws_demo*/98 loadGPSLocations(response );96 function (response) { 97 /* Runing on demo data bws_demo*/ 98 loadGPSLocations(response, true); 99 99 //loadGPSLocations(bws_demo); 100 100 } 101 ); 102 } 101 ); 102 } 103 103 104 104 function loadRoutesIntoDropdownBox() { … … 109 109 'get_routes_nonce': map_js_vars.get_routes_nonce 110 110 }, 111 function (response) {111 function (response) { 112 112 loadRoutes(response); 113 }); 113 }); 114 114 } 115 115 116 116 function loadRoutes(json) { 117 117 // console.log(JSON.stringify(json)); 118 118 119 119 if (json.length == 0 || json == '0') { 120 120 showMessage('There are no routes available to view'); … … 127 127 option.innerHTML = 'Select Route...'; 128 128 selectRoute.appendChild(option); 129 129 130 130 // when a user taps on a marker, the position of the sessionID in this array is the position of the route 131 131 // in the dropdown box. it's used below to set the index of the dropdown box when the map is changed … … 133 133 134 134 // iterate through the routes and load them into the dropdwon box. 135 $(json.routes).each(function (key, value){135 $(json.routes).each(function (key, value) { 136 136 var option = document.createElement('option'); 137 137 option.setAttribute('value', $(this).attr('session_id')); 138 138 option.innerHTML = $(this).attr('user_name') + " " + $(this).attr('times'); 139 139 selectRoute.appendChild(option); 140 140 141 141 sessionIDArray.push($(this).attr('session_id')); 142 142 }); … … 148 148 } 149 149 } 150 150 151 151 function getRouteForMap() { 152 152 $.post( … … 157 157 'get_geojson_route_nonce': map_js_vars.get_geojson_route_nonce 158 158 }, 159 function (response) {160 /* Runing on demo data bws_demo*/161 loadGPSLocations(response);159 function (response) { 160 /* Runing on demo data bws_demo*/ 161 loadGPSLocations(response); 162 162 //loadGPSLocations(bws_demo); 163 163 } 164 ); 165 } 166 167 function loadGPSLocations(geojson ) {164 ); 165 } 166 167 function loadGPSLocations(geojson, all_route = false) { 168 168 // console.log(JSON.stringify(geojson)); 169 169 … … 174 174 else { 175 175 176 var finalLocation = false;177 176 var finalLocation = false; 177 178 178 if (map.id == 'map-canvas') { 179 179 // clear any old map objects 180 180 document.getElementById('map-canvas').outerHTML = "<div id='map-canvas'></div>"; 181 181 182 182 // use leaflet (http://leafletjs.com/) to create our map and map layers 183 183 var gpsPlotterMap = new L.map('map-canvas'); 184 184 185 185 var openStreetMapsURL = ('https:' == document.location.protocol ? 'https://' : 'http://') + 186 '{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';186 '{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; 187 187 var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL, 188 {attribution:'©2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});188 { attribution: '©2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors' }); 189 189 190 190 // need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx 191 191 // var bingMapsLayer = new L.BingLayer("GetAKey"); 192 // var googleMapsLayer = new L.Google('ROADMAP');193 //console.log(map_type);192 // var googleMapsLayer = new L.Google('ROADMAP'); 193 //console.log(map_type); 194 194 var googleMapsLayer = new L.Google(map_type); 195 195 //var googleMapsLayer = new L.Google('HYBRID'); 196 197 198 196 197 198 199 199 // this fixes the zoom buttons from freezing 200 200 // https://github.com/shramov/leaflet-plugins/issues/62 201 L.polyline([[0, 0], ]).addTo(gpsPlotterMap);201 L.polyline([[0, 0],]).addTo(gpsPlotterMap); 202 202 203 203 // this sets which map layer will first be displayed, go ahead and change it to bingMapsLayer or openStreetMapsLayer to see 204 204 gpsPlotterMap.addLayer(googleMapsLayer); 205 205 206 206 207 207 // this is the switcher control to switch between map types (upper right hand corner of map) 208 208 gpsPlotterMap.addControl(new L.Control.Layers({ 209 209 // 'Bing Maps':bingMapsLayer, 210 'Google Maps': googleMapsLayer,210 'Google Maps': googleMapsLayer, 211 211 //'OpenStreetMaps':openStreetMapsLayer 212 212 }, {})); 213 213 } 214 214 215 215 var locationArray = []; 216 216 var latlngs = []; 217 217 218 for (var i = 0; i < $(geojson.features).length; i++) { 218 219 var longitude = geojson.features[i].geometry.coordinates[0]; 219 220 var latitude = geojson.features[i].geometry.coordinates[1]; 221 latlngs.push([latitude, longitude]); 220 222 221 223 var tempLocation = new L.LatLng(latitude, longitude); 222 locationArray.push(tempLocation); 224 locationArray.push(tempLocation); 223 225 224 226 if (i == ($(geojson.features).length) - 1) { 225 227 //gpsPlotterMap.setView(new L.LatLng(latitude, longitude), zoom); 226 228 finalLocation = true; 227 229 228 230 if (!viewingAllRoutes) { 229 231 displayCityName(latitude, longitude); 230 232 } 231 233 } 232 233 var marker = createMarker( 234 latitude, 235 longitude, 236 geojson.features[i].id, // session_id 237 geojson.features[i].properties.speed, 238 geojson.features[i].properties.direction, 239 geojson.features[i].properties.distance, 240 geojson.features[i].properties.location_method, 241 geojson.features[i].properties.gps_time, 242 geojson.features[i].properties.user_name, 243 geojson.features[i].properties.accuracy, 244 geojson.features[i].properties.extra_info, 245 gpsPlotterMap, finalLocation); 234 if (finalLocation == true || i == 0) { 235 var marker = createMarker( 236 latitude, 237 longitude, 238 geojson.features[i].id, // session_id 239 geojson.features[i].properties.speed, 240 geojson.features[i].properties.direction, 241 geojson.features[i].properties.distance, 242 geojson.features[i].properties.location_method, 243 geojson.features[i].properties.gps_time, 244 geojson.features[i].properties.user_name, 245 geojson.features[i].properties.accuracy, 246 geojson.features[i].properties.extra_info, 247 gpsPlotterMap, finalLocation); 248 } 246 249 }; 247 250 248 251 // fit markers within window 252 /*if (all_route == false) { 253 //console.log(latlngs); 254 var polyline = L.polyline(latlngs, { color: 'red' }).addTo(gpsPlotterMap); 255 }*/ 256 249 257 var bounds = new L.LatLngBounds(locationArray); 250 258 gpsPlotterMap.fitBounds(bounds); 251 259 252 260 // restarting interval here in case we are coming from viewing all routes 253 261 if (autoRefresh) { 254 262 restartInterval(); 255 } 256 } 257 } 258 263 } 264 } 265 } 266 259 267 // check to see if we have a map loaded, don't want to autoRefresh or delete without it 260 268 function hasMap() { 261 269 if (selectRoute.selectedIndex == 0) { // means no map 262 //console.log(false);270 //console.log(false); 263 271 return false; 264 272 } 265 273 else { 266 //console.log(true);274 //console.log(true); 267 275 return true; 268 276 } … … 270 278 271 279 function createMarker(latitude, longitude, session_id, speed, direction, distance, locationMethod, gpsTime, 272 userName, accuracy, extraInfo, map, finalLocation) {273 280 userName, accuracy, extraInfo, map, finalLocation) { 281 274 282 var iconUrl; 275 283 … … 279 287 iconUrl = pluginUrl + 'public/assets/images/coolgreen2_small.png'; 280 288 } 281 289 282 290 var markerIcon = new L.Icon({ 283 iconUrl:iconUrl,284 shadowUrl:pluginUrl + 'public/assets/images/coolshadow_small.png',285 iconSize:[12, 20],286 shadowSize:[22, 20],287 iconAnchor:[6, 20],288 shadowAnchor: [6, 20],289 popupAnchor:[-3, -25]291 iconUrl: iconUrl, 292 shadowUrl: pluginUrl + 'public/assets/images/coolshadow_small.png', 293 iconSize: [12, 20], 294 shadowSize: [22, 20], 295 iconAnchor: [6, 20], 296 shadowAnchor: [6, 20], 297 popupAnchor: [-3, -25] 290 298 }); 291 299 292 300 var lastMarker = "</td></tr>"; 293 301 … … 303 311 "<tr><td align=right> </td><td> </td><td rowspan=2 align=right>" + 304 312 "<img src=" + pluginUrl + "public/assets/images/" + getCompassImage(direction) + ".jpg alt= />" + lastMarker + 305 "<tr><td align=right>Speed: </td><td>" + speed + " mph</td></tr>" +306 "<tr><td align=right>Distance: </td><td>" + distance + " mi</td><td> </td></tr>" +307 "<tr><td align=right>Time: </td><td colspan=2>" + gpsTime + "</td></tr>" +313 "<tr><td align=right>Speed: </td><td>" + speed + " mph</td></tr>" + 314 "<tr><td align=right>Distance: </td><td>" + distance + " mi</td><td> </td></tr>" + 315 "<tr><td align=right>Time: </td><td colspan=2>" + gpsTime + "</td></tr>" + 308 316 "<tr><td align=right>UserName: </td><td>" + userName + "</td><td> </td></tr>" + 309 317 "<tr><td align=right>Accuracy: </td><td>" + accuracy + " ft</td><td> </td></tr></table>"; … … 314 322 // make sure the final red marker always displays on top 315 323 if (finalLocation) { 316 gpsplotterMarker = L.marker(new L.LatLng(latitude, longitude), { title: title, icon: markerIcon, zIndexOffset: 999}).bindPopup(popupWindowText).addTo(map);317 } else { 318 gpsplotterMarker = L.marker(new L.LatLng(latitude, longitude), { title: title, icon: markerIcon}).bindPopup(popupWindowText).addTo(map);319 } 320 324 gpsplotterMarker = L.marker(new L.LatLng(latitude, longitude), { title: title, icon: markerIcon, zIndexOffset: 999 }).bindPopup(popupWindowText).addTo(map); 325 } else { 326 gpsplotterMarker = L.marker(new L.LatLng(latitude, longitude), { title: title, icon: markerIcon }).bindPopup(popupWindowText).addTo(map); 327 } 328 321 329 // if we are viewing all routes, we want to go to a route when a user taps on a marker instead of displaying popupWindow 322 330 if (viewingAllRoutes) { 323 331 gpsplotterMarker.unbindPopup(); 324 325 gpsplotterMarker.on("click", function () {332 333 gpsplotterMarker.on("click", function () { 326 334 viewingAllRoutes = false; 327 335 328 336 var indexOfRouteInRouteSelectDropdwon = sessionIDArray.indexOf(session_id) + 1; 329 337 selectRoute.selectedIndex = indexOfRouteInRouteSelectDropdwon; 330 338 showPermanentMessage('Please select a route below'); 331 339 332 340 if (autoRefresh) { 333 restartInterval(); 341 restartInterval(); 334 342 } 335 343 336 344 $.post( 337 map_js_vars.ajax_url,345 map_js_vars.ajax_url, 338 346 { 339 347 'action': 'get_geojson_route', … … 341 349 'get_geojson_route_nonce': map_js_vars.get_geojson_route_nonce 342 350 }, 343 function (response) {344 351 function (response) { 352 345 353 loadGPSLocations(response); 346 354 } 347 ); 355 ); 348 356 }); // on click 349 } 357 } 350 358 } 351 359 352 360 function getCompassImage(azimuth) { 353 361 if ((azimuth >= 337 && azimuth <= 360) || (azimuth >= 0 && azimuth < 23)) 354 return 'compassN';362 return 'compassN'; 355 363 if (azimuth >= 23 && azimuth < 68) 356 return 'compassNE';364 return 'compassNE'; 357 365 if (azimuth >= 68 && azimuth < 113) 358 return 'compassE';366 return 'compassE'; 359 367 if (azimuth >= 113 && azimuth < 158) 360 return 'compassSE';368 return 'compassSE'; 361 369 if (azimuth >= 158 && azimuth < 203) 362 return 'compassS';370 return 'compassS'; 363 371 if (azimuth >= 203 && azimuth < 248) 364 return 'compassSW';372 return 'compassSW'; 365 373 if (azimuth >= 248 && azimuth < 293) 366 return 'compassW';374 return 'compassW'; 367 375 if (azimuth >= 293 && azimuth < 337) 368 return 'compassNW';376 return 'compassNW'; 369 377 370 378 return ""; 371 379 } 372 380 373 381 function displayCityName(latitude, longitude) { 374 382 var lat = parseFloat(latitude); … … 376 384 var latlng = new google.maps.LatLng(lat, lng); 377 385 reverseGeocoder = new google.maps.Geocoder(); 378 reverseGeocoder.geocode({ 'latLng': latlng}, function(results, status) {379 380 if (status == google.maps.GeocoderStatus.OK) {381 // results[0] is full address382 if (results[1]) {383 reverseGeocoderResult = results[1].formatted_address;384 showPermanentMessage(reverseGeocoderResult);385 } else {386 console.log('No results found');387 }386 reverseGeocoder.geocode({ 'latLng': latlng }, function (results, status) { 387 388 if (status == google.maps.GeocoderStatus.OK) { 389 // results[0] is full address 390 if (results[1]) { 391 reverseGeocoderResult = results[1].formatted_address; 392 showPermanentMessage(reverseGeocoderResult); 393 } else { 394 console.log('No results found'); 395 } 388 396 } else { 389 397 console.log('Geocoder failed due to: ' + status); … … 393 401 394 402 function deleteRoute() { 395 // comment out these two lines to get delete working396 // var answer = confirm("Disabled here on test website, this works fine.");397 // return false;398 403 // comment out these two lines to get delete working 404 // var answer = confirm("Disabled here on test website, this works fine."); 405 // return false; 406 399 407 var answer = confirm('This will permanently delete this route\n from the database. Do you want to delete?'); 400 401 if (answer) {408 409 if (answer) { 402 410 $.post( 403 411 map_js_vars.ajax_url, … … 407 415 'delete_route_nonce': map_js_vars.delete_route_nonce 408 416 }, 409 function (response) {417 function (response) { 410 418 map.innerHTML = ''; 411 419 selectRoute.length = 0; 412 420 413 421 loadRoutesIntoDropdownBox(); 414 422 getAllRoutesForMap(); 415 423 } 416 ); 424 ); 417 425 } 418 426 else { … … 424 432 function showMessage(message) { 425 433 // if we show a message like start auto refresh, we want to put back our current address afterwards 426 var tempMessage = $('#messages').html();434 var tempMessage = $('#messages').html(); 427 435 428 436 $('#messages').html(message); 429 setTimeout(function () {437 setTimeout(function () { 430 438 $('#messages').html(tempMessage); 431 439 }, 7 * 1000); // 7 seconds … … 439 447 showMessage('Auto Refresh Off'); 440 448 $('#autorefresh').val('Auto Refresh Off'); 441 449 442 450 autoRefresh = false; 443 clearInterval(intervalID); 444 } 445 446 function turnOnAutoRefresh() { 447 showMessage('Auto Refresh On (1 min)'); 451 clearInterval(intervalID); 452 } 453 454 function turnOnAutoRefresh() { 455 showMessage('Auto Refresh On (1 min)'); 448 456 $('#autorefresh').val('Auto Refresh On'); 449 457 autoRefresh = true; … … 451 459 restartInterval(); 452 460 } 453 461 454 462 function restartInterval() { 455 463 // remember that if someone is viewing all routes and then switches to a single route … … 458 466 459 467 clearInterval(intervalID); 460 468 461 469 if (viewingAllRoutes) { 462 470 intervalID = setInterval(getAllRoutesForMap, 60 * 1000); // one minute 463 471 } else { 464 intervalID = setInterval(getRouteForMap, 60 * 1000); 465 } 466 } 467 472 intervalID = setInterval(getRouteForMap, 60 * 1000); 473 } 474 } 475 468 476 // for debugging, console.log(objectToString(map)); 469 function objectToString (obj) {477 function objectToString(obj) { 470 478 var str = ''; 471 479 for (var p in obj) { … … 478 486 }); 479 487 480 481 488 -
gps-plotter/trunk/public/assets/js/gpsplotter-openmap.js
r2119607 r2648146 1 jQuery(document).ready(function ($) {1 jQuery(document).ready(function ($) { 2 2 var pluginUrl = map_js_vars.plugin_url; 3 3 var selectRoute = document.getElementById("selectRoute"); … … 18 18 loadRoutesIntoDropdownBox(); 19 19 20 $("#viewall").click(function () {20 $("#viewall").click(function () { 21 21 getAllRoutesForMap(); 22 22 }); 23 23 24 $("#bws_satelite").click(function () {24 $("#bws_satelite").click(function () { 25 25 if (map_type == "ROADMAP") { 26 26 map_type = "SATELLITE"; … … 40 40 }); 41 41 42 $("#selectRoute").on("change", function () {42 $("#selectRoute").on("change", function () { 43 43 if (hasMap()) { 44 44 viewingAllRoutes = false; … … 48 48 }); 49 49 50 $("#autorefresh").click(function () {50 $("#autorefresh").click(function () { 51 51 if (autoRefresh) { 52 52 turnOffAutoRefresh(); … … 56 56 }); 57 57 58 $("#delete").click(function () {58 $("#delete").click(function () { 59 59 if (hasMap()) { 60 60 deleteRoute(); … … 62 62 }); 63 63 64 $("#refresh").click(function() { 64 $("#refresh").click(function () { 65 var data = jQuery('#selectRoute').val(); 66 jQuery('#selectRoute').html(''); 67 loadRoutesIntoDropdownBox(); 68 69 setTimeout( 70 function() 71 { 72 jQuery('#selectRoute').val(data).trigger( "change" ); 73 74 }, 1000); 75 65 76 if (viewingAllRoutes) { 66 77 getAllRoutesForMap(); … … 92 103 get_all_geojson_routes_nonce: map_js_vars.get_all_geojson_routes_nonce 93 104 }, 94 function (response) {105 function (response) { 95 106 /* Runing on demo data bws_demo*/ 96 loadGPSLocations(response );107 loadGPSLocations(response, true); 97 108 //loadGPSLocations(bws_demo); 98 109 } … … 107 118 get_routes_nonce: map_js_vars.get_routes_nonce 108 119 }, 109 function (response) {120 function (response) { 110 121 loadRoutes(response); 111 122 } … … 131 142 132 143 // iterate through the routes and load them into the dropdwon box. 133 $(json.routes).each(function (key, value) {144 $(json.routes).each(function (key, value) { 134 145 var option = document.createElement("option"); 135 146 option.setAttribute("value", $(this).attr("session_id")); … … 156 167 get_geojson_route_nonce: map_js_vars.get_geojson_route_nonce 157 168 }, 158 function (response) {169 function (response) { 159 170 /* Runing on demo data bws_demo*/ 160 171 loadGPSLocations(response); … … 164 175 } 165 176 166 function loadGPSLocations(geojson ) {177 function loadGPSLocations(geojson, all_route = false) { 167 178 // console.log(JSON.stringify(geojson)); 168 179 … … 218 229 219 230 var locationArray = []; 231 var latlngs = []; 220 232 221 233 for (var i = 0; i < $(geojson.features).length; i++) { 222 234 var longitude = geojson.features[i].geometry.coordinates[0]; 223 235 var latitude = geojson.features[i].geometry.coordinates[1]; 224 236 latlngs.push([latitude, longitude]); 225 237 var tempLocation = new L.LatLng(latitude, longitude); 226 238 locationArray.push(tempLocation); … … 235 247 } 236 248 237 var marker = createMarker( 238 latitude, 239 longitude, 240 geojson.features[i].id, // session_id 241 geojson.features[i].properties.speed, 242 geojson.features[i].properties.direction, 243 geojson.features[i].properties.distance, 244 geojson.features[i].properties.location_method, 245 geojson.features[i].properties.gps_time, 246 geojson.features[i].properties.user_name, 247 geojson.features[i].properties.accuracy, 248 geojson.features[i].properties.extra_info, 249 gpsPlotterMap, 250 finalLocation 251 ); 252 } 253 249 if (finalLocation == true || i == 0) { 250 var marker = createMarker( 251 latitude, 252 longitude, 253 geojson.features[i].id, // session_id 254 geojson.features[i].properties.speed, 255 geojson.features[i].properties.direction, 256 geojson.features[i].properties.distance, 257 geojson.features[i].properties.location_method, 258 geojson.features[i].properties.gps_time, 259 geojson.features[i].properties.user_name, 260 geojson.features[i].properties.accuracy, 261 geojson.features[i].properties.extra_info, 262 gpsPlotterMap, 263 finalLocation 264 ); 265 } 266 } 267 268 /*if (all_route == false) { 269 //console.log(latlngs); 270 var polyline = L.polyline(latlngs, { color: 'red' }).addTo(gpsPlotterMap); 271 }*/ 272 254 273 // fit markers within window 255 274 var bounds = new L.LatLngBounds(locationArray); … … 369 388 gpsplotterMarker.unbindPopup(); 370 389 371 gpsplotterMarker.on("click", function () {390 gpsplotterMarker.on("click", function () { 372 391 viewingAllRoutes = false; 373 392 … … 388 407 get_geojson_route_nonce: map_js_vars.get_geojson_route_nonce 389 408 }, 390 function (response) {409 function (response) { 391 410 loadGPSLocations(response); 392 411 } … … 415 434 var latlng = new google.maps.LatLng(lat, lng); 416 435 reverseGeocoder = new google.maps.Geocoder(); 417 reverseGeocoder.geocode({ latLng: latlng }, function (results, status) {436 reverseGeocoder.geocode({ latLng: latlng }, function (results, status) { 418 437 if (status == google.maps.GeocoderStatus.OK) { 419 438 // results[0] is full address … … 447 466 delete_route_nonce: map_js_vars.delete_route_nonce 448 467 }, 449 function (response) {468 function (response) { 450 469 map.innerHTML = ""; 451 470 selectRoute.length = 0; … … 466 485 467 486 $("#messages").html(message); 468 setTimeout(function () {487 setTimeout(function () { 469 488 $("#messages").html(tempMessage); 470 489 }, 7 * 1000); // 7 seconds -
gps-plotter/trunk/readme.txt
r2570537 r2648146 130 130 == Changelog == 131 131 132 = 5.1.3 December 17, 2021 133 *fixed dropdown 134 132 135 = 5.1.2 July 22nd, 2021 133 136 -
gps-plotter/trunk/templates/shortcode-gpsplotter-map.php
r1918566 r2648146 1 2 1 <div id="pisol_gps_plotter"> 3 2 <div class="container-fluid">
Note: See TracChangeset
for help on using the changeset viewer.