Hexagon Geospatial
MENU

GeoMedia Smart Client

GeoMedia Smart Client community discussion board is where you can create, contribute and share information and knowledge in regards to configuring as well as working with GeoMedia Smart Client. Find your answers, share your knowledge and help build a strong GeoMedia Smart Client community.
Showing results for 
Search instead for 
Do you mean 
Reply
Occasional Contributor
Posts: 6
Registered: ‎02-06-2018
Accepted Solution

Get coordinates from map for URL

Hi Guys

 

I have an Action which is MAPCONTEXT and i'd like it to output the X and Y coordinates at the point im clicking right.

At the end the URL should look like this: https://hostname/?lookAtX=[X-coordinate]&lookAtY=[Y-coordinate]&looakAtZ=100 and open in the native Browser.

 

Does someone now what the syntax is?

 

Cheers

Frequent Contributor
Posts: 88
Registered: ‎04-02-2017

Re: Get coordinates from map for URL

Hi,

 

I have this working for a Google Street View link, but selecting a geometry from an active feature first and then centering the map.

 

IG.fitSelectedElements() to centre the map

var MapCent = IG.getMapCenter();
MapCent = String(MapCent);

 

then need to get the x and y 

 

var MapCentX = MapCent.substring(MapCent.indexOf('hor=')+4,34);
var MapCentY = MapCent.substring(MapCent.indexOf('vert=')+5,56);

 

then place these into your url.

Otherwise you can build a Java plugin to do this.

 

Josh

Occasional Contributor
Posts: 6
Registered: ‎02-06-2018

Re: Get coordinates from map for URL

[ Edited ]

Hi Josh

 

Thank you very much for replying.  How exactly do u implement the script in your workflow and how do you place the values in the URL?

Thank you for your help!

 

Cheers,

Fabian

Frequent Contributor
Posts: 88
Registered: ‎04-02-2017

Re: Get coordinates from map for URL

Hi Fabian,

 

The user selects a feature on the map, right clicks and selects the Google Street View action.

There is a form that appears on the side very briefly (unnoticed to the user) with some hidden fields so that the referenced Javascript runs.

The map centres on the point, the x and y are extracted from IG.getMapCentre() and the Ajax calls gets the lat/long and puts it in the Google Street View url.

 

Here is the Javascript

 

IG.vent.on('smartclient:ready', function() {
		
		IG.fitSelectedElements();
			
			var delay=500;
			setTimeout(function() {

				var MapCent = IG.getMapCenter();
				MapCent = String(MapCent);
				
				var MapCentX = MapCent.substring(MapCent.indexOf('hor=')+4,34);
				var MapCentY = MapCent.substring(MapCent.indexOf('vert=')+5,56);
				
                var url = 'http://epsg.io/trans?x=' + MapCentX + '&y=' + MapCentY + '&s_srs=28355&t_srs=4326';
				$.get(url, function(data){				
                    url = 'https://www.google.com.au/maps/@' + data.y + ',' + data.x + ',3a,89.9y,23.64h,86.56t/data=!3m6!1e1!3m4!1sKqmpLupTcWAzuGsYCeBV3g!2e0!7i13312!8i6656!6m1!1e1';				
					IG.browseInNativeBrowser(url);
					IG.closeWebBrowser();
				});
			});

});

It works on other machines, just not on mine. Intially the Javascript converted x and y to Lat Long with calculations, which worked fine for me.

I switched to the Ajax call to cut out unnecessary script and possible slower performance.

 

Regards,

 

Josh

Frequent Contributor
Posts: 88
Registered: ‎04-02-2017

Re: Get coordinates from map for URL

Sorry, I thought I was responding to another question.

 

- The user makes a feature active, selects it, right click>Google Street View.

  Browser location in the action is set to left so that form appears briefly on the left.

  • the form has hidden fields which are used for lat and long.
  • when the user right clicks and selects the action, the form loads briefly and the Javascript runs (which I included in the previous message).
  • IG.fitSelectedElements() centres the map on the selected feature
  • IG.MapCenter() returns a string that includes x and y.
  • I had to extract these numbers from the string with MapCentX and Y.
  • Then I build a url with these values and pass it to an Ajax request which converts to lat/long and opens Google Street View at that location.

 

Occasional Contributor
Posts: 6
Registered: ‎02-06-2018

Re: Get coordinates from map for URL

Hey Josh

 

Thank you a lot, you really helped me out here! Smiley Happy

 

Cheers,

Fabian

Frequent Contributor
Posts: 88
Registered: ‎04-02-2017

Re: Get coordinates from map for URL

I'm happy to give you more information on workflow/form/action settings.

This is just how I got it working. There may be other ways.

I also intially wanted to get the lat/long of the cursor location but this would involve building a Java plugin I think.

 

All the best

Polls
Please register to vote
Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.