Hexagon Geospatial
MENU

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
Occasional Contributor
Posts: 13
Registered: ‎08-23-2016
Accepted Solution

get ALL selected Features - URGENT - Geospatial Portal

[ Edited ]

Hi,

 

I want to get all the selected features from the map in Geospatial Portal.

The objective is to get features into geojson.

 

In our customisation, we add geojson data in different PSS from multi data sources.

We can select some of the features among those data, but we could also select features from WFS.

So, my problem is that I do not know in advance in which feature class the user will select the features.

 

Using the $GP.getSelectedFeatures.find() is not working without giving any parameter. I have to know in advance the featureclassID or the bounding box.

 

Is there a way to get ALL the features in the selected features from the map ?

 

--> I would expect to get all the selected feature with $GP.getSelectedFeatures.find() without giving any parameters..

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

Re: get ALL selected Features - URGENT - Geospatial Portal

Little bit of "hacking" into the API.js file and this code should work for you. The selected features are actually stored in a particular DOM object called Intergraph.WebSolutions.Core.WebClient.Platform.Data.SelectedFeaturesManager.

 

 

var selectedStorage = "Intergraph.WebSolutions.Core.WebClient.Platform.Data.SelectedFeaturesManager"

function getPortalObj(name) {       
  var chain = name.split("."),
      ret = window;
  for (var i = 0, l = chain.length; i < l; i++) {
    ret = ret[chain[i]];
    if (typeof ret === "undefined") break;
  }

  return ret;
}

console.log(getPortalObj(selectedStorage).getAllSelected());

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 13
Registered: ‎08-23-2016

Re: get ALL selected Features - URGENT - Geospatial Portal

Hi,

 

Thanks for your answer.

However, If I 'hack' the API, I will not have a 'core' solution anymore. At the next migration (installing the new API version), I will have to make the same tricks. 

 

The functionality to get all the selected features will be included in next version of the API ?

 

If yes, then maybe I can wait.

If no, this could be a big issue for our project and our client.

 

Thanks,

 

David

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

Re: get ALL selected Features - URGENT - Geospatial Portal

Hi Dave,

 

I see your point. I believe that this particular DOM object should not be really changed in any later release.

But yes, I will check with the development if there's other way or if they can populate such method in the API.

 

Regards

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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

Re: get ALL selected Features - URGENT - Geospatial Portal

[ Edited ]

So the official answer is that you can use $selectedFeatures.getAllSelected() and there's nothing wrong with that - it is just a “private API call" and should not change in future releases.

 

However… since EP05 you can use non-private API approach:

$GP.selectedFeatures.find({}, function (ret) {
    var obj = {};
    ret.featureClassIds.forEach(function (id, i) {
        obj[id] = ret.featureIds[i];
    });
    $GP.ui.info($GP.utils.serialize(obj));
});

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Occasional Contributor
Posts: 13
Registered: ‎08-23-2016

Re: get ALL selected Features - URGENT - Geospatial Portal

Ok ! Many thanks ! Smiley Happy

Highlighted
Occasional Contributor
Posts: 13
Registered: ‎08-23-2016

Re: get ALL selected Features - URGENT - Geospatial Portal

Hi,

 

 

Just to share the result of my work : 

 

I succeded to get the features (that i needed in GeoJson)

Here is my code : 

 

$GP.legend.find(null, function (ret) {
                var legend = ret;
                $GP.services.find({
                    mapServiceId: legend.legendItems[0]._.config.portalLegendItem._definition._mapService._id
                }, function (ret2) {
                    var services = ret2;
                    $GP.selectedFeatures.find({},
                    function (ret3) {
                        for (var i = 0; i < ret3.features[0].length; i++) {
                            var feat = ret3.features[0][i];
                            feat.get_geoJSON();
                            var result = feat._geoJSON;
// Do something with it. } }, function (err3) { var error3 = err3; }); }, function (err2) { var error2 = err2; }); }, function (err) { var error = err; });

 

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.