GMSC Discussions

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
Highlighted
Regular Contributor
Posts: 197
Registered: ‎07-07-2016

how to center to coordinates on standalone FormMapViewer map?

Hi,

I'm using GMSC2020. I've created standalone workflow containing FormMapViewer map. I need to center the map to some coordinates.

So, I've added a button that executes setCenter() function of MapViewer. But after click the button it centers me to the same point, no matter what are the setCenter() arguments. What could be the reason?

 

<FormMapViewer name="MapViewer" label=" " baseurl="https://war-hsiv-nidg.ingrnet.com/GMSC/Public/" site="GMSC" project="projekt_testowy">
<FormAction name="b1" label="center" action="SCRIPT[IG.getItemById('MapViewer').setCenter(14.1400, 49.0300)]" image="ig-icon-new"/>
</FormMapViewer>

Highlighted
Technical Evangelist
Posts: 833
Registered: ‎11-12-2015

Re: how to center to coordinates on standalone FormMapViewer map?

Hi mzebrows,

 

I'd have to set up a testbed to confrm and I dont use setCenter() often, but I believe the x/y needs to indicated.

So in your case something like this:

setCenter({x:14.1400, y:49.0300})

Have you considered using a script resource to setup and call the function from the standalone workflow? depending on your workflow desires it will become more efficient quickly.

 

Final question, are you wanting to just center the map on a particular x/y or do you wish to use this in a zoomTo or fit to point type of workflow?

Curious since I dont see setCenter used too often.

 

I hope that helps

Highlighted
Regular Contributor
Posts: 197
Registered: ‎07-07-2016

Re: how to center to coordinates on standalone FormMapViewer map?

Ad.1."setCenter({x:14.1400, y:49.0300})"

Unfortunatelly it still centers my map to the same point, no matter what coordinates are.

 

Ad.2."Have you considered using a script resource to setup and call the function from the standalone workflow? "

Do You mean something like this?

<Form name="NewForm2" editable="true" idfield="ID" table="GCW.CMENTARZ" customscript="Test.js">
    <FormTab name="NewTabPage1" editable="true" visible="true">
      <FormGroup name="NewGroup1" editable="true" visible="true">
        <FormField name="ID" editable="true" visible="true" datatype="number" required="true" persisted="true" saveinsession="false" type="textfield" override="false" />
		<FormMapViewer name="MapViewer" label=" " baseurl="https://war-hsiv-nidg.ingrnet.com/GMSC/Public/" site="GMSC" project="projekt_testowy">
		 <FormAction name="center" label="test" action="SCRIPT[center()]" image="ig-icon-new"/>
		</FormMapViewer>
      </FormGroup>
    </FormTab>
  </Form>

Ad.3 "are you wanting to just center the map on a particular x/y or do you wish to use this in a zoomTo or fit to point type of workflow"

I have a table TABLE1 with some records. My goal is to display a form with concrete record attributes and a map with geometry of that record. So I think that I need to center the map to this geometry and zoom in. 

Highlighted
Staff
Posts: 1,131
Registered: ‎10-18-2015

Re: how to center to coordinates on standalone FormMapViewer map?

Here is a script function that should work (you can put it in a custom script triggered by mapViewer:ready event.

 

function goToCurrent (mapViewer, id) {
	if(!_.isEmpty(id)){
   mapViewer.map.loadPoi('d8b69386-1db1-4a69-a683-9d41118beca5',id) // this is the ID of the POI feature in the GMSC schema
   .done(function(response){
		var activeMapView = IG.getItemById('MapViewer').map.getActiveMapView();
		activeMapView.center.lon(response.properties.pointLocationX);
                activeMapView.center.lat( response.properties.pointLocationY);
                activeMapView.zoomTo(11);
		});
	}
}
Stefano Turcato
Presale Engineer
Hexagon Geospatial
Highlighted
Regular Contributor
Posts: 197
Registered: ‎07-07-2016

Re: how to center to coordinates on standalone FormMapViewer map?

Still the same.

zoomTo(11) works properly

but 

activeMapView.center.lon(14.1400);
activeMapView.center.lat(49.0300);

does not work.

 

It still centers the map to the same point.

 

Highlighted
Staff
Posts: 1,131
Registered: ‎10-18-2015

Re: how to center to coordinates on standalone FormMapViewer map?

I don't understand why you want to provide coordinates in plain text. Don't you have a geometry for your feature?

if you want to switch between different records it is enough to get the ID in the form. For instance in this form I configured a formtable and I can fit each point individually using the function I mentioned in the previous post.

 

<FormTable name="NeighboringPOIs" idfield="Id" label="List of Neighboring POIs (within 100 m)"
	lov="SQL[SELECT p2.Id, p2.Borough, p2.Type, p2.Location, case p2.Status when 0 then 'Pending' when 1 then 'Approved' when 2 then 'Declined' end as Status  FROM 
	poi_workflow p1, poi_workflow p2 where 
	p1.geometry_spa.STDistance(p2.GEOMETRY_SPA)&lt;100 and p1.ID={FORM.ID} and p2.ID!={FORM.ID}]" persisted="false"  selectionmode="none">
	 <FormTableField name="Type"  />
	 <FormTableField name="Borough"/>
	 <FormTableField name="Location"/>
	 <FormTableField name="Status"/>
	 <FormAction name="ZoomtoPOI" label="Zoom to the POI location"  action="SCRIPT[goToCurrent(IG.getItemById('MapViewer'), {ROW.Id})]" type="row" image="ig-icon-search" />
</FormTable>	
Stefano Turcato
Presale Engineer
Hexagon Geospatial
Highlighted
Regular Contributor
Posts: 197
Registered: ‎07-07-2016

Re: how to center to coordinates on standalone FormMapViewer map?

gmsc_center2.pngOk, I've changed my solution to use POI.Now it looks similar to Your solution.

But unfortunatelly the sourcecode inside mapViewer.map.loadPoi(...)done() is never executed. 

What can be the reason for this? I