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
Highlighted
Super Contributor
Posts: 301
Registered: ‎02-09-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

HI Jan,

 

Thank you for confirming that. I thought it didn't work because I didn't do it right.

 

Kind regards,

Highlighted
Occasional Contributor
Posts: 12
Registered: ‎01-03-2018

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Well, after following all the thread instructions, i finally success on creating WMPS Searches, configure them, and even after a few try/error i succeed in personalize all the tooltips, results, and detailed info.

Let me resume it, so maybe it can help someone.

 

At SearchConfiguration, i selected:

WMPS Search Attributes.png --> WMPS Search Attributes filled.png

 

The 'Search Result Type' and 'Feature Attribute' corresponds to data.properties.type and data.properties.description fields, of every future result element you get from your search.

 

So you can select a 'Search Result Type' field from your feature, knowing for example in my case, that  CAPA_GENERICA, is an attribute where will be some "Restaurants"

 

Fields Values.PNG

 

and configure the template.json like this:

 

template json with restaurants.png

In the green section, "wmpssearch" is DEFAULT behaviour for WMPS Searches results. In there, the "default" subsection (in orange) refears to default behaviour for tooltip, resultlist and detailed, but the "restaurants" is the behaviour for every element that has a data.properties.type = "restaurants".

 

Like this, you can create new .tmpl files, refer them in new "type" section, according to Search Result Type field values you have in the choosen field, and configure specific tmpl files, depending on the values/types you have.

 

The values you can show, as JAN said, are available in a collection of attributes.

Every element has the following structure:

 

 

 

{
               "id" : "",
               "properties" : {
                              "name" : "",
                              "description" : "",
                              "type" : "",
                              "original" : {
                                            "Attributes" : [{key, value}]
                              },
                              "serviceType" : "WMPSSearch",
                              "x1" : XMin,
                              "x2" : Xmax,
                              "y1" : YMin,
                              "y2" : YMax
               },
               "geometry" : {
                              "coordinates" : [X, Y],
                              "type" : "Point"
               },
               "type" : "Feature",
               "crs" : {
                              "type" : "name",
                              "properties" : {
                                            "name" : "EPSG:XXXX"
                              }
               }
}

 

 

so, on data.properties.original.Attributes[i], you have all the attributes and properties from your FeatureElement.

Here I show you for example some of my "basic" tooltips:

 

 

<div class="webgis-search-result-marker-tooltip-type-<%=(data.properties.type || 'none').toLowerCase()%>">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description"><%=data.properties.description%></div>
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type"><%=data.properties.original.Attributes[2].Value%></div>
	<div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type"><%=data.properties.original.Attributes[3].Value%></div>
	<br />
	<%debugger;%>
	<% _.forOwn(data.properties.original.Attributes, function(value, key) { %>
	  <% if(value.Key != "GEOMETRIA" && value.Key != "COORD_X" && value.Key != "COORD_Y" && value.Value != "" && value.Value != undefined) { %>
	  <%=value.Key%> : <%=value.Value%>
	  <br />
	  <% } %>
    <%});%>	
	<br />
</div>

and the result is something like this:

 

tooltip default.png

 

or more simple, in the "restaurants" case (restaurants.tooltip.tmpl)

 

<div class="webgis-search-result-marker-tooltip-type-<%=(data.properties.type || 'none').toLowerCase()%>">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description"><%=data.properties.original.Attributes[8].Value%></div>
	<br />
	<div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-detail-item-info-telf">Telf: <%=data.properties.original.Attributes[10].Value%></div>
	<div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type">Adr: <%=data.properties.original.Attributes[14].Value%></div>
	<br />
</div>

 

and the result is something like this:

 

tooltip restaurants.png

 

They are both from same WMPS Search, but diferent element types, the first one is the default tooltip, the second one is a Restaurant type result.

 

CSS

 

All the .tmpl files, has a div class references, so you can change the style, changing the CSS file:

../CONSUMERPORTAL/resources/style/style.css

 

Adding new CSS styles or modifying the webgis-search-result-marker-tooltip-item styles you need.

 

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Hi bferrer and Jan,

 

What is different in extracting attributes for oracle search?

I have tried the same logic, but it doesn't work.

 

Regards,

Mladen

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

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Hi Mladen,

 

Have you tried using this template and see what you get as a result?

<div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description">City Name: <%=data.properties.description%></div>
  <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type">State Name: <%=data.properties.type%></div>
    <% _.forOwn(data.properties.original.Attributes, function(value, key) { %>
      <%=value.Key%> : <%=value.Value%>
      <br />
   <%});%>
</div>

Alternatively, you can put console.log(), alert(), or debugger; calls into the template and see what data comes from the Oracle searcher. In general, there should be no difference in structure when compared to WMPS.

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Maybe try first with the simplest template.json possible (note the custom part by the end):

{
    "default":
    {
        "default":
        {
            "resultlist": "resources/templates/default.resultlist.tmpl",
            "tooltip": "resources/templates/default.tooltip.tmpl",
            "detailed": "resources/templates/default.detailed.tmpl"
        }
    },
    "searchbackend":
    {
        "cemetery": "resources/templates/default",
        "church": "resources/templates/default",
        "city": "resources/templates/default",
        "county": "resources/templates/default",
        "firestation": "resources/templates/default",
        "interstate": "resources/templates/default",
        "lake": "resources/templates/default",
        "river": "resources/templates/default",
        "road": "resources/templates/default",
        "school": "resources/templates/default",
        "state": "resources/templates/default",
        "street": "resources/templates/default"
    },
    "apollocatalog":
    {
        "imagereference":
        {
            "detailed": "resources/templates/imagereference.detailed.tmpl"
        }
    },
    "wmpssearch":
    {
        "default": "resources/templates/default",
        "city": "resources/templates/default"
    },
    "searchbackend":
    {
		"default": 
		{		
			"tooltip": "resources/templates/custom/custom.tooltip.tmpl"
		}
	}
}
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

Hi Jan,

 

Using this

<div class="webgis-search-result-marker-tooltip-type-<%=(data.properties.type || 'none').toLowerCase()%>">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description"><%=data.properties.description%></div>
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type"><%=data.properties.type%></div>
	<% _.forOwn(data.properties, function(value, key) { %>
	<div class="webgis-search-result-moreinfo-item webgis-search-result-moreinfo-item-<%=key%>">
	<%=value%>
	</div> 
	<%});%>
</div>

I can display all attributes in tooltip, but I can not figure how to displej just some of attributes.

Capture.JPG

 

Mladen

Highlighted
Contributor
Posts: 49
Registered: ‎04-14-2016

Re: Configuring the Template in Consumer Portal Layout - WMPS search

I have found a solution.
 
In my case (probably because oracle search) every element has following structure:
{
  "results": [
    {
      "type": "Feature",
      "properties": {
        "serviceType": "SearchBackend",
        "type": "Ulcinj",
        "description": "K.O. ULCINJ",
        "y1": 41.96641197793253,
        "x1": 19.180977329654166,
        "y2": 41.89974531126587,
        "x2": 19.247643996320836
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          19.2143106629875,
          41.9330786445992
        ]
      }
    }
  ],
  "final": true
}
I used following template do display attribute x2 in addition to description and type
<div class="webgis-search-result-marker-tooltip-type-<%=(data.properties.type || 'none').toLowerCase()%>">
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description"><%=data.properties.description%></div>
    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-type"><%=data.properties.type%></div>

    <div class="webgis-search-result-marker-tooltip-item webgis-search-result-marker-tooltip-item-description">Additional atribute: <%=data.properties.x2%></div>

</div>
Now it looks good.
Capture.JPG
 
Regards,
Mladen