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
DN
Contributor
Posts: 49
Registered: ‎10-27-2015
Accepted Solution

Styling query results

Is it possible to style query results using Portal SDK?

Below is how new query is added. Results are displayed using default colours/syles. What I would like is to change this default behaviour.

Any help is appreciated.

 

$GP.ready(function () {

    $GP.ui.toolbar.add({

                  categoryIndex: 0,

       xtype: "tbbutton",

       text: "WMPSQuery",

       handler: function (b) {

                                             $GP.map.draw({

                                                            "type": "Polygon" //user will be promped to draw geometry (polygon) on map

                                             }, function (r) {

                                                                           createAnalysis(r.feature.get_geoJSON().geometry);

                                             });

    }

    });

});

 

 function createAnalysis(geometry) {

               //$GP.crs.setCurrent("EPSG:4326", function () {

                              $GP.queries.add({

                                             featureClassId: "USSample|States",

                                             url: "http://swi-sgiv-gm19.ingrnet.com/USAWMPS/MapService.svc",

                                             definitionName: "MapPublisher",

                                             queryName: "Query with drawing",

                                             applicationId: "USDemoWMPS",

                                             addToLegend: true,

                                             filters: [{

                                                                           type: "spatial",

                                                                           operator: "0",

                                                                           complement: false,

                                                                           operands: [geometry]

                                             }]

                                            

                              },

                              function (result) {

                                             $GP.map.draw.clear();

                              });

               //});

};

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

Re: Styling query results

Hi Denis,

 

There are two options as far as I can think up (I did not test them though):

  • Temporarily rewrite the predefined default styles:
    The default styles can be accessed through: Sys.Application.Configuration.StyleConfig.definitions
    The definition https://hexagongeospatial.fluidtopics.net/en/book#!book;uri=6697fdd22b671e45d0341bf9ef4659cf;breadcr...

     

    So for each query:

    1) Try to modify the StyleConfig.definitions object and change the default "analysis" styles

    2) Add the Query into Portal

    3) (Optionally) revert the default styles to their original values after the Query is loaded in the application window.

  • Use dynamicStyles each time before calling query. Create a style and put the $GP.queries.add function in the callback
    $GP.dynamicStyles.register({
        featureClassId: "someId",
        default: function (feature) {
             return {
                 "style": {
                     "color": "#f00",
                     "name": "Red Line",
                     "width": 10,
                     "translucency": 0.2
                 },
                 defaultStyleName: "none",
                 styleType: "Intergraph.WebSolutions.Core.WebClient.Platform.Style.SimpleLineStyle"
             }
        }
    }, function () {
    		$GP.queries.add({
    			 featureClassId: "someId",
    			 url: "http://web.address",
    			 definitionName: "WFS",
    			 queryName: queryName,
    			 addToLegend: false
    		},
    		function(result) {
    			// do something
    		});
    });
    http://demo.hexagongeospatial.com/communityportal/docs/index.html#!/api/$GP.dynamicStyles
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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

Re: Styling query results

Some update:

  • The styling engine does not seem to work perfectly, I remember trying to use same style (red lines) for all types like default, highlight, analysis, redlining, .... but I was not able to force the WMPS service to apply that style. It did not even apply the custom style when I worked directly in the GUI.
  • I have dug in our issue reporting system and found out that this is a known problem but has low priority at this moment. Workaround is to set the geometry type in the legend from Compound to the actual type, but this is AFAIK not possible with SDK :-(
  • So the most usable workaround is to switch over to WFS
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

DN
Contributor
Posts: 49
Registered: ‎10-27-2015

Re: Styling query results

Hi Jan,

 

do you remember the SR number for this issue?

 

Thanks,

Denis

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

Re: Styling query results

If I remember correctly the CR # is 1-FFF80M.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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