WebGIS Discussions

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 40
Registered: ‎07-12-2016
Accepted Solution

Is there a Geospatial Portal 2016 API method for zooming to a WMPS feature?

[ Edited ]

I found the example to zoom to an Apollo feature, which looks like:

 

function finish(response) {
 response.results[0].zoom(callback);
}

function example() {
 $GP.search({
 searchType: "apollo",
 keywords: "Cherokee"
 }, finish)
}

 

I want to do something similar on a WMPS feature, like this:

 

function finish(response) {
	response.featureId.zoom(callback);
}

function select() {
    $GP.selectedFeatures.add({
        featureId: featureId,
        featureClassId: featureClassId
    }, finish);
}

 

but I get the error:

 

         response.featureId.zoom is not a function

 

Is there another way of zooming to a WMPS feature?

 

Thanks.

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

Re: Is there a Geospatial Portal 2016 API method for zooming to a WMPS feature?

Hi Jason,

 

Yes, it looks like this method is not populated in the SDK. The selectedFeatures returns Feature object offering those methods (functions):

  • center
  • get_featureClassId
  • get_GeoJSON
  • get_id

 

To zoom to this feature, I would:

  1. Use get_GeoJSON
  2. Calculcate BBOX of this GeoJSON, for instance using this free JS library https://github.com/geosquare/geojson-bbox
  3. If needed, transform the coordinates to the map CRS
  4. Use $GP.map.zoom with the bbox parameter

 

Regards,

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 40
Registered: ‎07-12-2016

Re: Is there a Geospatial Portal 2016 API method for zooming to a WMPS feature?

Thanks Jan, this a good solution for now.

 

Regards,

Jason