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 
Reply
Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016
Accepted Solution

Fill the fields in custom side bar from URL

Hi all,

 

I have a Geospatial Portal instance with a custom sidebar for coordinate transformation.

Capture.PNG

The first two fields in the sidebar are for data input and when user type coordinates in the fields and click on the button "find and transform" application transforms coordinates to other coordinate systems and zoom to the location.

 

Is there any way to create a solution that will do the following:

  • If user put in URL two coordinates (for example   http://myserver/myinstance/full.aspx?x=40.2458&y=21.45879)
  • Geospatial portal put that two coordinates in fields on my custom sidebar and perform transformation and zoom to the location.

Best regards,

Mladen

 

 

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Fill the fields in custom side bar from URL

Hi All,

 

Using this

 

function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    });
    return vars;}

var xurl = getUrlVars()["iks"];
var yurl = getUrlVars()["ipsilon"];
	
if (yurl > 0) {
	document.getElementById("X_field").value = xurl;
	document.getElementById("Y_field").value = yurl;}

I can populate fields based on URL http://hostname/instancename?iks=42.44129&ipsilon=19.26289

 

Using

document.getElementById("transform_button").click();

I can simulate click on the button, but now I have a problem that pan to the location is not performed.

 

If I click on the button manually pan, zoom and add pin is performed, but when I am opening the page with predefined parameters for x and y in URL zoom to scale and add pin is performed, but the pan is not performed.

 

$GP.map.zoom({x:x, y:y, scaleDenominator : 1000});
$GP.map.pin.add({x: x, y:y});

any advice?

 

 

 

 

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

Re: Fill the fields in custom side bar from URL

Hi Mladen,

 

Have you seen this?

https://hexagongeospatial.fluidtopics.net/reader/YS8lbCzq66les82OrxFhTg/vDCK0p0NACtiHsjK7xXFZg

 

Depending on Portal version, these URL parameters should work too. There was a problem with the bbox but I am unsure in which version it was fixed at the moment.

 

In addition, do you call the $GP.map.zoom as a part of $GP.ready(), i.e. after the Portal is completely loaded? It may be that the map settings overrides this function, if called too early.

I would also recommend to add the errback function (3rd argument) to see if there's any error message.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Fill the fields in custom side bar from URL

Hi Jan,

 

Yes, I have seen this article already.

It works in my instance, but this is not applicable in this case.

 

There are 4 different coordinate systems (EPSG4326, EPSG32634, EPSG31276, EPSG31277) that customer uses and we need a solution that can recognize in which system are coordinates from url and to transform it to map coordinate system.

 

As I mentioned, we already have "coordinate calculator" implemented, and I need just to "press" the button after map is loaded.

 

I do not use $GP.ready() in my code.

It looks like that the map settings override my function (it overrride just pan, not zoom), but I do not know how to resolve this.

 

Best regards,

Mladen

 

 

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Fill the fields in custom side bar from URL

I resolved the problem with function setDelay().

Now I "press" the button after map is loaded with a short delay.

 

It is not the best option, but it works.

 

Best regards,

Mladen