Issue with layer bounds

2 posts / 0 new
Last post
Issue with layer bounds

Hello, I have been trying to access the bounds of a RouteLayer without success. I am able to call the getBounds() function on a RouteLayer, but the value returned is NULL rather than a latLngBounds object. I have included a JSFiddle-compatible example below. It generates two popups-- one with the result of calling getBounds() on the map itself, and the other calling it on the layer. The application I'm working on requires getting an individual layer's bounds.


       var map ='map', {
            layers: MQ.mapLayer(),
            center: [38.575210, -121.483426],
            zoom: 12

       var dir2 = MQ.routing.directions();

            locations: [
              "woodland, ca",
              "dixon, ca"

     var layer1 = MQ.routing.routeLayer({
            directions: dir2,
            fitBounds: true


Make sure the bounds are
Make sure the bounds are requested after the layer has bounds - in the success event of the directions request. Here is how I did it.          var dir2 = MQ.routing.directions()        .on('success', function(data){        try{            console.log(layer1.routeData.boundingBox);        }catch(e){}        });