Improved www.ttss.krakow.pl
c5a5c333b5b930ccc8d879067eddd874313f9574..01853e8919f80dd24d7864b2f5a4232cf475b5dc
2020-11-02 Jacek Kowalski
[map] Fix removing currently selected feature
01853e diff | tree
2020-11-02 Jacek Kowalski
[map] Fix differential data support
42c5bf diff | tree
2020-11-02 Jacek Kowalski
[map] Fix vehicle search
3a4fe8 diff | tree
1 files modified
15 ■■■■■ changed files
map.js 15 ●●●●● patch | view | raw | blame | history
map.js
@@ -188,7 +188,7 @@
        });
        
        ttss_types.forEach(function(ttss_type) {
            vehicles_source[ttss_type].forEachFeature(function(feature) {
            vehicles[ttss_type].source.forEachFeature(function(feature) {
                if(feature.get('vehicle_type') && feature.get('vehicle_type').num.indexOf(query) > -1) {
                    features.push(feature);
                }
@@ -268,12 +268,6 @@
            }),
            text: new ol.style.Text({
                font: 'bold 10px sans-serif',
                // TODO: special directions
                // vehicle.line = vehicle.name.substr(0, vehicle_name_space);
                // vehicle.direction = normalizeName(vehicle.name.substr(vehicle_name_space+1));
                // if(special_directions[vehicle.direction]) {
                //     vehicle.line = special_directions[vehicle.direction];
                // }
                text: feature.get('line'),
                fill: new ol.style.Fill({color: 'white'}),
            }),
@@ -328,10 +322,10 @@
    },
    _removeFeature: function(feature) {
        if(!feature) return;
        this.source.removeFeature(feature);
        if(this.selectedFeatureId === feature.getId()) {
            this.deselect();
        }
        this.source.removeFeature(feature);
    },
    loadFullData: function(data) {
        var self = this;
@@ -386,12 +380,15 @@
            api_url + '/positions/?type=' + this.prefix + '&last=' + this.lastUpdate
        ).done(function(data) {
            try {
                if(data['date'] < self.lastUpdate) {
                    console.log('Data older than lastUpdate!');
                }
                if(data['type'] == 'full') {
                    self.loadFullData(data['pos']);
                } else {
                    self.loadDiffData(data['pos']);
                }
                self.lastUpdate = data['last'];
                self.lastUpdate = data['date'];
                setTimeout(self.fetchXhr.bind(self), api_refresh);
            } catch(e) {
                console.log(e);