Hexagon Geospatial
MENU

Smart M.App

Looking for answers in regards to M.Apps, M.App Exchange or M.App Studio? Smart M.App Tech Discussion board is where you can search, ask your questions and assist others by sharing your knowledge. Join the conversation, connect, contribute and share.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 34
Registered: ‎10-21-2016
Accepted Solution

Bounding box data not accepted by zoom-function

Hello everybody,

 

I have a working Smart M.App, made out of a recipe panel and a BI Map panel. A choropleth is drawn near Rotterdam, Netherlands, and it works, as well as the charts. 

Out of the GeoJSON which is used, I can extract the bounding box information. I checked and made sure they are the correct coordinates. I have been trying to implement a zoom function using these coordinates:

 

gsp.map.zoom({"bbox": [4.538801, 51.915823, 4.552856, 51.918814], "animationTime": 1}, 
function zoomSuccess(){
console.log(arguments);
}, onError
);

 

The problem is: every time it zooms to the same location [0, 0, 0, 0]. I've tried many configurations, but it seems like the boundingbox-data is removed from the function, in some way. Maybe the function expects the arguments in a different format.

 

Does anyone have experience with this? I read a topic which is quite similar to this one, but I can't find a solution over there either. I was wondering if there is currently anyone who knows the reason or has a solution for this.

 

Regards,

Vincent

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: Bounding box data not accepted by zoom-function

Hi Vincent,

 

your coordinates look to be in WGS84 (EPSG:4326) but the maps actually use EPSG:3857 (by default). Please have a look at this sample code available in M.App Studio, you might need to do the coordinates translation:

 

// transform sample points to current CRS
gsp.crs.transform({
    points: [bottomLeftCorner, topRightCorner],
    sourceCrsId: "EPSG:4326",
    targetCrsId: gsp.crs.getCurrent()
}, function (transformationResult) {
    // get BBOX in form minx, miny, maxx, maxy
    var points = transformationResult.points,
        bbox = [points[0].x, points[0].y, points[1].x, points[1].y];
    gsp.map.zoom({
        bbox: bbox
    }, function () {
        // display information
        gsp.map.info(function(ret){           
            gsp.ui.info(gsp.utils.serialize(ret)); 
        });
    });
});

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Contributor
Posts: 34
Registered: ‎10-21-2016

Re: Bounding box data not accepted by zoom-function

Thanks a lot Jan, it works! 

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.