1

I am using the following loop for displaying the a bus route. 'stopLonLat' is a JavaScript object with all the latitude and longitude values of various bus stops. Since I am not looking for shortest path between origin and destination, I consider each bus stops, find route between them and draw the route in the loop.

     var startLon,startLat,destLon,destLat,viewparams,params;

        for(var i=0;i<stopLonLat.length-1;i=i+1) {

                 startLon= 'x1:' + stopLonLat[i].Longitude; 
                 startLat= 'y1:' + stopLonLat[i].Latitude;

                 destLon='x2:' + stopLonLat[i+1].Longitude;
                 destLat='y2:' + stopLonLat[i+1].Latitude;
                 viewparams = [
                  startLon,startLat,
                  destLon,destLat
                ];
                params = {
                      LAYERS: 'pgrouting:pgrouting2',
                      FORMAT: 'image/png',
                      viewparams:viewparams.join(';')
                };
                //params.viewparams = viewparams.join(';');
                routeLayer = new ol.layer.Tile({
                  source: new ol.source.TileWMS({
                    url: 'http://localhost:8080/geoserver/pgrouting/wms',
                    params: params
                  })
                });   

                me.getOMap().addLayer(routeLayer);
        }

Now there are two problems I am facing.

  1. Since there will be a lot of number of bus stops in a route of 200km to 700 km, there will be that much 'routeLayer' will be created. Which makes map rendering extensively slow.
  2. I cannot remove the layer 'routeLayer'

I don't know whether the procedure I'm following is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.