05-30-2016 03:04 PM
HI Jan,
Thank you for confirming that. I thought it didn't work because I didn't do it right.
Kind regards,
09-18-2018 02:43 AM
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:
-->
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"
and configure the template.json like this:
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:
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:
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.
06-17-2020 04:19 AM
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
06-17-2020 05:16 AM
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.
06-17-2020 06:15 AM
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" } } }
06-18-2020 12:33 AM
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.
Mladen
06-18-2020 03:40 AM
{ "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>