Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Technical Evangelist
Posts: 1,382
Registered: ‎09-11-2015

Re: zoom to bounding box url for SDK

[ Edited ]

You can place it anywhere to a script which is loaded by the Portal, so e.g. HelloWorld.js, or other custom script. Of course do not embed any irrelevant code inside such as creating the Hello World button, I left it there by mistake.


This is the fully working code. I have rewritten the parameter getter because this one looks better :-)


window.onload = function () {

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec( || [null, ''])[1].replace(/\+/g, '%20')) || null;

function zoomToBBox() {
    bbox = getURLParameter("bounds");
    if (bbox == null) return;
    bbox = bbox.split(",");

    //sample points in EPSG:4326
    var bottomLeftCorner = { x: bbox[0], y: bbox[1] },
        topRightCorner = { x: bbox[2], y: bbox[3] };

        points: [bottomLeftCorner, topRightCorner],
        sourceCrsId: "EPSG:4326", 
        targetCrsId: $,
    }, 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];
            bbox: bbox
        }, function () {
            // display information

Sample URL:




Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 244
Registered: ‎05-01-2016

Re: zoom to bounding box url for SDK

This works great!  Map redraws in the correct spot after portal loads.