Plugin Directory

Changeset 2648146


Ignore:
Timestamp:
12/23/2021 03:58:31 AM (4 years ago)
Author:
Chilifide
Message:

Fixed drop-down.

Location:
gps-plotter/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • gps-plotter/trunk/gpsplotter.php

    r2570534 r2648146  
    44Plugin URI: https://www.stpetedesign.com/gps-plotter/
    55Description: 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.2
     6Version: 5.1.3
    77Author: Steve Curtis, St. Pete Design
    88Author URI: https://www.stpetedesign.com/gps-plotter/
  • gps-plotter/trunk/includes/class-gpsplotter-setup.php

    r1857574 r2648146  
    9999        $procedure_name =  $wpdb->prefix . "get_routes";
    100100        $wpdb->query( "DROP PROCEDURE IF EXISTS {$procedure_name};" );
    101            
     101       
    102102        $sql = "CREATE PROCEDURE {$procedure_name}()
    103103        BEGIN
    104         CREATE TEMPORARY TABLE temp_routes (
     104       
     105        CREATE TEMPORARY TABLE IF NOT EXISTS temp_routes (
    105106            session_id VARCHAR(50),
    106107            user_name VARCHAR(50),
     
    115116        UPDATE temp_routes tr
    116117        SET start_time = (SELECT MIN(gps_time) FROM {$table_name} gl
    117         WHERE gl.session_id = tr.session_id
    118         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 );
    119120
    120121        UPDATE temp_routes tr
    121122        SET end_time = (SELECT MAX(gps_time) FROM {$table_name} gl
    122         WHERE gl.session_id = tr.session_id
    123         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 );
    124125
    125126        SELECT
     
    144145        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
    145146        FROM {$table_name}
    146         WHERE session_id = _session_id
     147        WHERE session_id COLLATE utf8mb4_general_ci = _session_id COLLATE utf8mb4_general_ci
    147148        ORDER BY last_update;
    148149        END;";
  • gps-plotter/trunk/public/assets/js/gpsplotter-map.js

    r1857574 r2648146  
    1 jQuery(document).ready(function($) {
     1jQuery(document).ready(function ($) {
    22    var pluginUrl = map_js_vars.plugin_url;
    33    var selectRoute = document.getElementById('selectRoute');
    4     var map = document.getElementById('map-canvas'); 
     4    var map = document.getElementById('map-canvas');
    55    var intervalID = 0;
    6     var zoom = 12; 
     6    var zoom = 12;
    77    var autoRefresh = false;
    88    var sessionIDArray = [];
    99    var viewingAllRoutes = false;
    10    
    11     var map_type = "ROADMAP";
    12    
     10
     11    var map_type = "ROADMAP";
     12
    1313    /* demo response
    1414    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]}}]};
    1515    */
    16    
     16
    1717
    1818    getAllRoutesForMap();
    1919    loadRoutesIntoDropdownBox();
    20    
    21     $("#viewall").click(function() {
     20
     21    $("#viewall").click(function () {
    2222        getAllRoutesForMap();
    2323    });
    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        }
    3333
    3434        if (viewingAllRoutes) {
    35             getAllRoutesForMap(); 
     35            getAllRoutesForMap();
    3636        } else {
    3737            if (hasMap()) {
    3838                getRouteForMap();
    39             } 
    40         }
    41     });
    42    
    43 
    44     $('#selectRoute').on('change', function() {
     39            }
     40        }
     41    });
     42
     43
     44    $('#selectRoute').on('change', function () {
    4545        if (hasMap()) {
    4646            viewingAllRoutes = false;
    47              
     47
    4848            getRouteForMap();
    49         } 
    50     }); 
    51 
    52     $('#autorefresh').click(function() {
     49        }
     50    });
     51
     52    $('#autorefresh').click(function () {
    5353        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 () {
    6161        if (hasMap()) {
    6262            deleteRoute();
    63         }             
    64     }); 
    65 
    66     $("#refresh").click(function() {
     63        }
     64    });
     65
     66    $("#refresh").click(function () {
    6767        if (viewingAllRoutes) {
    68             getAllRoutesForMap(); 
     68            getAllRoutesForMap();
    6969        } else {
    7070            if (hasMap()) {
    7171                getRouteForMap();
    72             } 
    73         }
    74     }); 
    75    
     72            }
     73        }
     74    });
     75
    7676    function setTheme() {
    7777        //var bodyBackgroundColor = $('body').css('backgroundColor');
     
    8080        // $('head').append('<link rel="stylesheet" href="style2.css" type="text/css" />');       
    8181    }
    82    
     82
    8383    function getAllRoutesForMap() {
    8484        // when the page first loads, get the routes from the DB and load them into the dropdown box.
    85        
     85
    8686        viewingAllRoutes = true;
    8787        //selectRoute.selectedIndex = 0;
    8888        showPermanentMessage('Please select a route below');
    89                
     89
    9090        $.post(
    91             map_js_vars.ajax_url,
     91            map_js_vars.ajax_url,
    9292            {
    9393                'action': 'get_all_geojson_routes',
    9494                'get_all_geojson_routes_nonce': map_js_vars.get_all_geojson_routes_nonce
    9595            },
    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);
    9999                //loadGPSLocations(bws_demo);
    100100            }
    101         );   
    102     } 
     101        );
     102    }
    103103
    104104    function loadRoutesIntoDropdownBox() {
     
    109109                'get_routes_nonce': map_js_vars.get_routes_nonce
    110110            },
    111             function(response) {
     111            function (response) {
    112112                loadRoutes(response);
    113             });   
     113            });
    114114    }
    115115
    116116    function loadRoutes(json) {
    117117        // console.log(JSON.stringify(json));
    118                
     118
    119119        if (json.length == 0 || json == '0') {
    120120            showMessage('There are no routes available to view');
     
    127127            option.innerHTML = 'Select Route...';
    128128            selectRoute.appendChild(option);
    129            
     129
    130130            // when a user taps on a marker, the position of the sessionID in this array is the position of the route
    131131            // in the dropdown box. it's used below to set the index of the dropdown box when the map is changed
     
    133133
    134134            // 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) {
    136136                var option = document.createElement('option');
    137137                option.setAttribute('value', $(this).attr('session_id'));
    138138                option.innerHTML = $(this).attr('user_name') + "  " + $(this).attr('times');
    139139                selectRoute.appendChild(option);
    140                
     140
    141141                sessionIDArray.push($(this).attr('session_id'));
    142142            });
     
    148148        }
    149149    }
    150    
     150
    151151    function getRouteForMap() {
    152152        $.post(
     
    157157                'get_geojson_route_nonce': map_js_vars.get_geojson_route_nonce
    158158            },
    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);
    162162                //loadGPSLocations(bws_demo);
    163163            }
    164         );   
    165     }
    166 
    167     function loadGPSLocations(geojson) {
     164        );
     165    }
     166
     167    function loadGPSLocations(geojson, all_route = false) {
    168168        // console.log(JSON.stringify(geojson));
    169169
     
    174174        else {
    175175
    176             var finalLocation = false;
    177            
     176            var finalLocation = false;
     177
    178178            if (map.id == 'map-canvas') {
    179179                // clear any old map objects
    180180                document.getElementById('map-canvas').outerHTML = "<div id='map-canvas'></div>";
    181            
     181
    182182                // use leaflet (http://leafletjs.com/) to create our map and map layers
    183183                var gpsPlotterMap = new L.map('map-canvas');
    184            
     184
    185185                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';
    187187                var openStreetMapsLayer = new L.TileLayer(openStreetMapsURL,
    188                 {attribution:'&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'});
     188                    { attribution: '&copy;2014 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors' });
    189189
    190190                // need to get your own bing maps key, http://www.microsoft.com/maps/create-a-bing-maps-key.aspx
    191191                // 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);
    194194                var googleMapsLayer = new L.Google(map_type);
    195195                //var googleMapsLayer = new L.Google('HYBRID');
    196                
    197                
    198            
     196
     197
     198
    199199                // this fixes the zoom buttons from freezing
    200200                // https://github.com/shramov/leaflet-plugins/issues/62
    201                 L.polyline([[0, 0], ]).addTo(gpsPlotterMap);
     201                L.polyline([[0, 0],]).addTo(gpsPlotterMap);
    202202
    203203                // this sets which map layer will first be displayed, go ahead and change it to bingMapsLayer or openStreetMapsLayer to see
    204204                gpsPlotterMap.addLayer(googleMapsLayer);
    205                
     205
    206206
    207207                // this is the switcher control to switch between map types (upper right hand corner of map)
    208208                gpsPlotterMap.addControl(new L.Control.Layers({
    209209                    // 'Bing Maps':bingMapsLayer,
    210                     'Google Maps':googleMapsLayer,
     210                    'Google Maps': googleMapsLayer,
    211211                    //'OpenStreetMaps':openStreetMapsLayer
    212212                }, {}));
    213213            }
    214            
     214
    215215            var locationArray = [];
    216            
     216            var latlngs = [];
     217
    217218            for (var i = 0; i < $(geojson.features).length; i++) {
    218219                var longitude = geojson.features[i].geometry.coordinates[0];
    219220                var latitude = geojson.features[i].geometry.coordinates[1];
     221                latlngs.push([latitude, longitude]);
    220222
    221223                var tempLocation = new L.LatLng(latitude, longitude);
    222                 locationArray.push(tempLocation); 
     224                locationArray.push(tempLocation);
    223225
    224226                if (i == ($(geojson.features).length) - 1) {
    225227                    //gpsPlotterMap.setView(new L.LatLng(latitude, longitude), zoom);
    226228                    finalLocation = true;
    227                    
     229
    228230                    if (!viewingAllRoutes) {
    229231                        displayCityName(latitude, longitude);
    230232                    }
    231233                }
    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                }
    246249            };
    247            
     250
    248251            // 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
    249257            var bounds = new L.LatLngBounds(locationArray);
    250258            gpsPlotterMap.fitBounds(bounds);
    251            
     259
    252260            // restarting interval here in case we are coming from viewing all routes
    253261            if (autoRefresh) {
    254262                restartInterval();
    255             }                       
    256         }
    257     }
    258    
     263            }
     264        }
     265    }
     266
    259267    // check to see if we have a map loaded, don't want to autoRefresh or delete without it
    260268    function hasMap() {
    261269        if (selectRoute.selectedIndex == 0) { // means no map
    262         //console.log(false);
     270            //console.log(false);
    263271            return false;
    264272        }
    265273        else {
    266             //console.log(true);
     274            //console.log(true);
    267275            return true;
    268276        }
     
    270278
    271279    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
    274282        var iconUrl;
    275283
     
    279287            iconUrl = pluginUrl + 'public/assets/images/coolgreen2_small.png';
    280288        }
    281    
     289
    282290        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]
    290298        });
    291        
     299
    292300        var lastMarker = "</td></tr>";
    293301
     
    303311            "<tr><td align=right>&nbsp;</td><td>&nbsp;</td><td rowspan=2 align=right>" +
    304312            "<img src=" + pluginUrl + "public/assets/images/" + getCompassImage(direction) + ".jpg alt= />" + lastMarker +
    305             "<tr><td align=right>Speed:&nbsp;</td><td>" + speed +  " mph</td></tr>" +
    306             "<tr><td align=right>Distance:&nbsp;</td><td>" + distance +  " mi</td><td>&nbsp;</td></tr>" +
    307             "<tr><td align=right>Time:&nbsp;</td><td colspan=2>" + gpsTime +  "</td></tr>" +
     313            "<tr><td align=right>Speed:&nbsp;</td><td>" + speed + " mph</td></tr>" +
     314            "<tr><td align=right>Distance:&nbsp;</td><td>" + distance + " mi</td><td>&nbsp;</td></tr>" +
     315            "<tr><td align=right>Time:&nbsp;</td><td colspan=2>" + gpsTime + "</td></tr>" +
    308316            "<tr><td align=right>UserName:&nbsp;</td><td>" + userName + "</td><td>&nbsp;</td></tr>" +
    309317            "<tr><td align=right>Accuracy:&nbsp;</td><td>" + accuracy + " ft</td><td>&nbsp;</td></tr></table>";
     
    314322        // make sure the final red marker always displays on top
    315323        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
    321329        // if we are viewing all routes, we want to go to a route when a user taps on a marker instead of displaying popupWindow
    322330        if (viewingAllRoutes) {
    323331            gpsplotterMarker.unbindPopup();
    324            
    325             gpsplotterMarker.on("click", function() {       
     332
     333            gpsplotterMarker.on("click", function () {
    326334                viewingAllRoutes = false;
    327  
     335
    328336                var indexOfRouteInRouteSelectDropdwon = sessionIDArray.indexOf(session_id) + 1;
    329337                selectRoute.selectedIndex = indexOfRouteInRouteSelectDropdwon;
    330338                showPermanentMessage('Please select a route below');
    331                
     339
    332340                if (autoRefresh) {
    333                     restartInterval(); 
     341                    restartInterval();
    334342                }
    335                    
     343
    336344                $.post(
    337                    map_js_vars.ajax_url,
     345                    map_js_vars.ajax_url,
    338346                    {
    339347                        'action': 'get_geojson_route',
     
    341349                        'get_geojson_route_nonce': map_js_vars.get_geojson_route_nonce
    342350                    },
    343                     function(response) {
    344                        
     351                    function (response) {
     352
    345353                        loadGPSLocations(response);
    346354                    }
    347                 ); 
     355                );
    348356            }); // on click
    349         } 
     357        }
    350358    }
    351359
    352360    function getCompassImage(azimuth) {
    353361        if ((azimuth >= 337 && azimuth <= 360) || (azimuth >= 0 && azimuth < 23))
    354                 return 'compassN';
     362            return 'compassN';
    355363        if (azimuth >= 23 && azimuth < 68)
    356                 return 'compassNE';
     364            return 'compassNE';
    357365        if (azimuth >= 68 && azimuth < 113)
    358                 return 'compassE';
     366            return 'compassE';
    359367        if (azimuth >= 113 && azimuth < 158)
    360                 return 'compassSE';
     368            return 'compassSE';
    361369        if (azimuth >= 158 && azimuth < 203)
    362                 return 'compassS';
     370            return 'compassS';
    363371        if (azimuth >= 203 && azimuth < 248)
    364                 return 'compassSW';
     372            return 'compassSW';
    365373        if (azimuth >= 248 && azimuth < 293)
    366                 return 'compassW';
     374            return 'compassW';
    367375        if (azimuth >= 293 && azimuth < 337)
    368                 return 'compassNW';
     376            return 'compassNW';
    369377
    370378        return "";
    371379    }
    372    
     380
    373381    function displayCityName(latitude, longitude) {
    374382        var lat = parseFloat(latitude);
     
    376384        var latlng = new google.maps.LatLng(lat, lng);
    377385        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 address
    382               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                }
    388396            } else {
    389397                console.log('Geocoder failed due to: ' + status);
     
    393401
    394402    function deleteRoute() {
    395         // comment out these two lines to get delete working
    396         // 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
    399407        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) {
    402410            $.post(
    403411                map_js_vars.ajax_url,
     
    407415                    'delete_route_nonce': map_js_vars.delete_route_nonce
    408416                },
    409                 function(response) {
     417                function (response) {
    410418                    map.innerHTML = '';
    411419                    selectRoute.length = 0;
    412                
     420
    413421                    loadRoutesIntoDropdownBox();
    414422                    getAllRoutesForMap();
    415423                }
    416             ); 
     424            );
    417425        }
    418426        else {
     
    424432    function showMessage(message) {
    425433        // 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();
    427435
    428436        $('#messages').html(message);
    429         setTimeout(function() {
     437        setTimeout(function () {
    430438            $('#messages').html(tempMessage);
    431439        }, 7 * 1000); // 7 seconds
     
    439447        showMessage('Auto Refresh Off');
    440448        $('#autorefresh').val('Auto Refresh Off');
    441    
     449
    442450        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)');
    448456        $('#autorefresh').val('Auto Refresh On');
    449457        autoRefresh = true;
     
    451459        restartInterval();
    452460    }
    453    
     461
    454462    function restartInterval() {
    455463        // remember that if someone is viewing all routes and then switches to a single route
     
    458466
    459467        clearInterval(intervalID);
    460        
     468
    461469        if (viewingAllRoutes) {
    462470            intervalID = setInterval(getAllRoutesForMap, 60 * 1000); // one minute
    463471        } else {
    464             intervalID = setInterval(getRouteForMap, 60 * 1000);         
    465         }         
    466     }
    467  
     472            intervalID = setInterval(getRouteForMap, 60 * 1000);
     473        }
     474    }
     475
    468476    // for debugging, console.log(objectToString(map));
    469     function objectToString (obj) {
     477    function objectToString(obj) {
    470478        var str = '';
    471479        for (var p in obj) {
     
    478486});
    479487
    480        
    481        
     488
  • gps-plotter/trunk/public/assets/js/gpsplotter-openmap.js

    r2119607 r2648146  
    1 jQuery(document).ready(function($) {
     1jQuery(document).ready(function ($) {
    22  var pluginUrl = map_js_vars.plugin_url;
    33  var selectRoute = document.getElementById("selectRoute");
     
    1818  loadRoutesIntoDropdownBox();
    1919
    20   $("#viewall").click(function() {
     20  $("#viewall").click(function () {
    2121    getAllRoutesForMap();
    2222  });
    2323
    24   $("#bws_satelite").click(function() {
     24  $("#bws_satelite").click(function () {
    2525    if (map_type == "ROADMAP") {
    2626      map_type = "SATELLITE";
     
    4040  });
    4141
    42   $("#selectRoute").on("change", function() {
     42  $("#selectRoute").on("change", function () {
    4343    if (hasMap()) {
    4444      viewingAllRoutes = false;
     
    4848  });
    4949
    50   $("#autorefresh").click(function() {
     50  $("#autorefresh").click(function () {
    5151    if (autoRefresh) {
    5252      turnOffAutoRefresh();
     
    5656  });
    5757
    58   $("#delete").click(function() {
     58  $("#delete").click(function () {
    5959    if (hasMap()) {
    6060      deleteRoute();
     
    6262  });
    6363
    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   
    6576    if (viewingAllRoutes) {
    6677      getAllRoutesForMap();
     
    92103        get_all_geojson_routes_nonce: map_js_vars.get_all_geojson_routes_nonce
    93104      },
    94       function(response) {
     105      function (response) {
    95106        /* Runing on demo data bws_demo*/
    96         loadGPSLocations(response);
     107        loadGPSLocations(response, true);
    97108        //loadGPSLocations(bws_demo);
    98109      }
     
    107118        get_routes_nonce: map_js_vars.get_routes_nonce
    108119      },
    109       function(response) {
     120      function (response) {
    110121        loadRoutes(response);
    111122      }
     
    131142
    132143      // 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) {
    134145        var option = document.createElement("option");
    135146        option.setAttribute("value", $(this).attr("session_id"));
     
    156167        get_geojson_route_nonce: map_js_vars.get_geojson_route_nonce
    157168      },
    158       function(response) {
     169      function (response) {
    159170        /* Runing on demo data bws_demo*/
    160171        loadGPSLocations(response);
     
    164175  }
    165176
    166   function loadGPSLocations(geojson) {
     177  function loadGPSLocations(geojson, all_route = false) {
    167178    // console.log(JSON.stringify(geojson));
    168179
     
    218229
    219230      var locationArray = [];
     231      var latlngs = [];
    220232
    221233      for (var i = 0; i < $(geojson.features).length; i++) {
    222234        var longitude = geojson.features[i].geometry.coordinates[0];
    223235        var latitude = geojson.features[i].geometry.coordinates[1];
    224 
     236        latlngs.push([latitude, longitude]);
    225237        var tempLocation = new L.LatLng(latitude, longitude);
    226238        locationArray.push(tempLocation);
     
    235247        }
    236248
    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     
    254273      // fit markers within window
    255274      var bounds = new L.LatLngBounds(locationArray);
     
    369388      gpsplotterMarker.unbindPopup();
    370389
    371       gpsplotterMarker.on("click", function() {
     390      gpsplotterMarker.on("click", function () {
    372391        viewingAllRoutes = false;
    373392
     
    388407            get_geojson_route_nonce: map_js_vars.get_geojson_route_nonce
    389408          },
    390           function(response) {
     409          function (response) {
    391410            loadGPSLocations(response);
    392411          }
     
    415434    var latlng = new google.maps.LatLng(lat, lng);
    416435    reverseGeocoder = new google.maps.Geocoder();
    417     reverseGeocoder.geocode({ latLng: latlng }, function(results, status) {
     436    reverseGeocoder.geocode({ latLng: latlng }, function (results, status) {
    418437      if (status == google.maps.GeocoderStatus.OK) {
    419438        // results[0] is full address
     
    447466          delete_route_nonce: map_js_vars.delete_route_nonce
    448467        },
    449         function(response) {
     468        function (response) {
    450469          map.innerHTML = "";
    451470          selectRoute.length = 0;
     
    466485
    467486    $("#messages").html(message);
    468     setTimeout(function() {
     487    setTimeout(function () {
    469488      $("#messages").html(tempMessage);
    470489    }, 7 * 1000); // 7 seconds
  • gps-plotter/trunk/readme.txt

    r2570537 r2648146  
    130130== Changelog ==
    131131
     132= 5.1.3 December 17, 2021
     133*fixed dropdown
     134
    132135= 5.1.2 July 22nd, 2021
    133136
  • gps-plotter/trunk/templates/shortcode-gpsplotter-map.php

    r1918566 r2648146  
    1 
    21<div id="pisol_gps_plotter">
    32<div class="container-fluid">
Note: See TracChangeset for help on using the changeset viewer.