Class: searchDirective directive:gmfSearch

gmf.searchDirective

new searchDirective(gmfSearchTemplateUrl)

A directive that allows to search and recenter on a selected result's feature. It can search in multiple GeoJSON datasources. It can filter and group results by a feature's property.

This directive uses the ngeo.FeatureOverlayMgr to create a feature overlay for drawing features on the map. The application is responsible to initialize the ngeo.FeatureOverlayMgr with the map.

Example flat results:

 <gmf-search gmf-search-map="ctrl.map"
   gmf-search-options="ctrl.searchOptions"
   gmf-search-styles="ctrl.searchStyles"
   gmf-search-datasources="ctrl.searchDatasources"
   gmf-search-coordinatesprojections="ctrl.searchCoordinatesProjections"
   gmf-search-delay="mainCtrl.searchDelay"
   gmf-search-clearbutton="true">
 </gmf-search>
 <script>
   (function() {
     let module = angular.module('app');
     module.value('fulltextsearchUrl', '${request.route_url('fulltextsearch', _query={"limit": 20, "ranksystem": "similarity"}) | n}');
     module.value('gmfSearchGroups', []);
     module.constant('gmfSearchActions', [
           {action: 'add_theme', title: 'Add a theme'},
           {action: 'add_group', title: 'Add a sub theme'},
           {action: 'add_layer', title: 'Add a layer'}
     ]);
   })();
 </script>

Example with categories:

 <gmf-search gmf-search-map="ctrl.map"
   gmf-search-options="ctrl.searchOptions"
   gmf-search-styles="ctrl.searchStyles"
   gmf-search-datasources="ctrl.searchDatasources"
   gmf-search-coordinatesprojections="ctrl.searchCoordinatesProjections"
   gmf-search-clearbutton="true"
   gmf-search-delay="mainCtrl.searchDelay"
   gmf-search-colorchooser="true">
 </gmf-search>
 <script>
   (function() {
     let module = angular.module('app');
     module.value('fulltextsearchUrl', '${request.route_url('fulltextsearch', _query={"limit": 30, "partitionlimit": 5}) | n}');
     module.value('gmfSearchGroups', ${dumps(fulltextsearch_groups) | n});
     module.value('gmfSearchActions', []);
   })();
 </script>

The 'fulltextsearchUrl' value in the examples above set three "_query" parameters: "limit", "partitionlimit" and "ranksystem". For this last one "similarity" is the only effective value. It's used to order your search results with the "similarity" ranking system from PostgreSQL module pg_trgm. Without this value, the PostgreSQL function "ts_rank_cd" is used for the ranking. Read the full-text search c2cgeoportal documentation to know more. You can also add these parameters to the "url" variable of one (or more) of the gmfx.SearchDirectiveDatasource given to this component (here within the "ctrl.searchDatasources"). That allows you to have multiples configurations on one search component.

HTML attributes:
Name Type Description
gmf-search-input-value string The input value (read only).
gmf-search-map ol.Map The map.
gmf-search-options TypeaheadOptions | undefined Addition Typeahead options.
gmf-search-datasource gmfx.SearchDirectiveDatasource The datasources.
gmf-search-styles Object:.<string:, ol.style.Style:> A map of styles to apply on searched features. Keys must be the 'layer_name' propertie of features except for coordinates where the key ifor its style is the value of the constant 'gmf.COORDINATES_LAYER_NAME'. The 'default' key is used to apply the default style.
gmf-search-coordinatesprojections Array:.<string:> codes of supported projections for coordinates search (projections must be defined in ol3). If not provided, only the map's view projection format will be supported.
gmf-search-clearbutton boolean The clear button.
gmf-search-delay boolean The bloodhound request delay.
gmf-search-colorchooser boolean Whether to let the user change the style of the feature on the map. Default is false.
gmf-search-listeners ngeox.SearchDirectiveListeners The listeners.
gmf-search-maxzoom number The maximum zoom we will zoom on result, default is 16.
gmf-search-on-init function Optional function called when the directive is initialized.
Returns:
angular.Directive

The Directive Definition Object.