01-10-2020 12:04 AM
Hi all,
I have a Geospatial Portal instance with a custom sidebar for coordinate transformation.
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:
Best regards,
Mladen
Solved! Go to Solution.
01-15-2020 12:34 AM
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?
01-22-2020 12:01 AM
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.
01-22-2020 05:54 AM
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
01-23-2020 12:42 AM
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