~costales/unav/0.67-public-line

« back to all changes in this revision

Viewing changes to nav/class/UI.js

  • Committer: costales
  • Date: 2017-03-04 12:53:36 UTC
  • Revision ID: costales.marcos@gmail.com-20170304125336-b05y2vx2jvw410dk
WIP

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
        });
98
98
        this.map.addLayer(route_line);
99
99
        
 
100
        this.routeSourcePublic = new ol.source.Vector({});
 
101
        var route_line_public = new ol.layer.Vector({
 
102
                source: this.routeSourcePublic,
 
103
                style: [
 
104
                        new ol.style.Style({
 
105
                                stroke: new ol.style.Stroke({
 
106
                                        color: '#FFD7C8',
 
107
                                        width: 6
 
108
                                })
 
109
                        }),
 
110
                        new ol.style.Style({
 
111
                                stroke: new ol.style.Stroke({
 
112
                                        color: '#E95420',
 
113
                                        width: 4
 
114
                                })
 
115
                        })
 
116
                ]
 
117
        });
 
118
        this.map.addLayer(route_line_public);
 
119
        
100
120
        this.online_layer = 0;
101
121
        
102
122
        this.scaleline = new ol.control.ScaleLine();
242
262
UI.prototype.set_map_layer = function(layer) {
243
263
        var aux_center = this.map.getView().getCenter();
244
264
        var aux_zoom = this.map.getView().getZoom();
245
 
        var layers_max_ind = this.map.getLayers().getArray().length - 2; // Route is another layer (6 map layers = 0 to 5)
 
265
        var layers_max_ind = this.map.getLayers().getArray().length - 3; // 8 tiles (0-7) + map + 2 line routes
246
266
        
247
267
        if (layer == 99) // Independent of number of layers
248
268
                layer = layers_max_ind; 
250
270
                layer = 0;
251
271
        this.online_layer = layer;
252
272
 
253
 
        // 0 OSM, 1 Terrain, 2 Toner, 3 OpenTopoMap, 4 Mapbox, Last=Offline
 
273
        // 0 OSM, 1 Terrain, 2 Toner, 3 OpenTopoMap, 4 Mapbox, 5 Carto Positron, 6 Carto Dark, 7 Last=Offline
254
274
        for (i=0; i<=layers_max_ind; i++) {
255
275
                if (i == layer) {
256
276
                        this.map.getLayers().getArray()[i].setVisible(true);
273
293
                }
274
294
        }
275
295
        
276
 
        if (layer == layers_max_ind) {
 
296
        if (layer == layers_max_ind) { // Offline = unknow tiles
277
297
                $('#map_attribution').hide();
278
298
                $(".map").addClass('body_bg');
279
299
        }
336
356
UI.prototype.route = function(redraw_map) {
337
357
        if (this.nav.get_route_status() !== 'drawing' && this.nav.get_route_status() !== 'simulate_drawing') {
338
358
                this.routeSource.clear();
 
359
                this.routeSourcePublic.clear();
339
360
                return;
340
361
        }
341
362
        
342
363
        this.map.getView().setRotation(0);
343
364
        
344
365
        this.routeSource.clear();
 
366
        this.routeSourcePublic.clear();
345
367
        
346
368
        var lineString = new ol.geom.LineString(this.nav.get_route_line_map());
347
369
        lineString.transform('EPSG:4326', 'EPSG:3857');
348
 
        var routepoints = new ol.Feature({
349
 
                geometry: lineString
350
 
        });
351
 
        this.routeSource.addFeature(routepoints);
 
370
        this.routeSource.addFeature(
 
371
                new ol.Feature({
 
372
                        geometry: lineString
 
373
                })
 
374
        );
 
375
        
 
376
        //var lineStringPublic = new ol.geom.MultiLineString(this.nav.get_route_line_map());
 
377
        //lineStringPublic.transform('EPSG:4326', 'EPSG:3857');
 
378
        //this.routeSourcePublic.addFeature(
 
379
        //      new ol.Feature({
 
380
        //              geometry: lineStringPublic
 
381
        //      })
 
382
        //);
352
383
        
353
384
        // Fit route to view
354
385
        if (redraw_map) {