Search

Overview

The search for spatial objects such as addresses, POIs or parcels is a central function in many apps. The bundle omnisearch provides an interface that is optimized for use on desktop and mobile devices and offers a central input field for the search. Several other bundles can provide data sources for searches without having to provide a graphical interface. If more than one data source is available, the user can choose between them.

omnisearch

Interface

Required Bundles: omnisearch, at least one data source bundle

Zooming to a result

When a search result is selected, the view is zoomed to the bounding box of the found object, if it is a line or polygon.

Point objects are zoomed to a preconfigured scale of the found object. This is defined as follows:

{
  "omnisearch": {
    "ZoomHandler": {
      "scale": 1000
    }
  }
}

Optionally, zooming to a fixed scale is possible for line or polygon objects. This requires the following configuration:

{
  "omnisearch": {
    "ZoomHandler": {
      "scale": 1000,
      "fixedScale": true
    }
  }
}

It is possible to set different scales for different data sources. The respective ID defines a mapping of data source and scale.

{
  "omnisearch": {
    "ZoomHandler": {
      "scaleByStore": {
        "store01": 5000,
        "store02": 25000
      }
    }
  }
}

Show popups for a search result

To display a default popup for a search result, set popupEnabled to true and add the popups-default bundle to your app.

{
    "agssearch": {
        "AGSStore": [
            {
                "id": "Airports",
                "url": "https://myserver/arcgis/rest/services/Airports/MapServer/0",
                "popupEnabled": true
            }
        ]
    }
}

To display an individual popup for a search result, configure a popupTemplate as in the following sample:

{
    "agssearch": {
        "AGSStore": [
            {
                "id": "Airports",
                "url": "https://myserver/arcgis/rest/services/Airports/MapServer/0",
                "popupTemplate": {
                    "title": " {name}",
                    "content": [
                        {
                            "type": "fields",
                            "fieldInfos": [
                                {
                                    "fieldName": "myfield",
                                    "label": "My field"
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}

For an overview about how to configure individual popups, see custom popups.

Display of a result

Search results are displayed in the map depending on their geometry: A marker for points and a geometry highlighting for lines and areas. The representation can be changed by configuration.

Symbols are defined according to the Esri Symbol Definition . To configure 3D symbols, the postfix -3d must be appended to the geometry type.

The following configuration shows the default values for each type:

{
  "omnisearch": {
    "DrawHandler": {
      "_symbolTable": {
        "point": {
          "url": "resource('images/mapMarker.png')",
          "width": 37,
          "height": 36,
          "xoffset": 4,
          "yoffset": 16,
          "type": "esriPMS"
        },
        "polyline": {
          "color": [
            10,
            10,
            10,
            255
          ],
          "style": "esriSLSSolid",
          "type": "esriSLS",
          "width": 1.3
        },
        "polygon": {
          "type": "esriSFS",
          "style": "esriSFSSolid",
          "color": [
            125,
            205,
            234,
            100
          ],
          "outline": {
            "type": "esriSLS",
            "style": "esriSLSSolid",
            "color": [
              10,
              10,
              10,
              255
            ],
            "width": 1
          }
        },
        "point-3d": {
          "url": "resource('images/mapMarker.png')",
          "width": 37,
          "height": 36,
          "xoffset": 4,
          "yoffset": 16,
          "type": "esriPMS"
        },
        "polyline-3d": {
          "color": [
            10,
            10,
            10,
            255
          ],
          "style": "esriSLSSolid",
          "type": "esriSLS",
          "width": 1.3
        },
        "polygon-3d": {
          "type": "esriSFS",
          "style": "esriSFSSolid",
          "color": [
            125,
            205,
            234,
            100
          ],
          "outline": {
            "type": "esriSLS",
            "style": "esriSLSSolid",
            "color": [
              10,
              10,
              10,
              255
            ],
            "width": 1
          }
        }
      }
    }
  }
}
For more information about configuration, refer to the bundle documentation .

Data sources

ArcGIS Map or Feature Layer

Required Bundle: agssearch

ArcGIS Map or Feature layers supporting the query operation can be used as data sources.

Automatic registration

If the automatic registration is active and the parameter useIn contains the value omnisearch, all ArcGIS map and feature layers visible in the map are used for the search.

The displayField from the metadata of the service is used for the search. The title of the layer and its description are also requested from the service.

This configuration can be done in the manual configuration as follows:

{
    "agssearch": {
        "AutoStoreRegistration": {
            "componentEnabled": true,
            "useIn": [
                "omnisearch",
                "selection"
            ]
        }
    }
}

Manual registration

With the following configuration, layers used in the map can be registered for the search:

{
    "agssearch": {
        "AGSStore": [
            {
                "id": "store01",
                "title": "Gemeinden in Deutschland (MapServer Layer)",
                "layerId": "grenzen/0",
                "useIn": [
                    "omnisearch"
                ],
                "omniSearchSearchAttr": "g_name",
                "omniSearchDefaultLabel": "Enter search term...",
                "omniSearchPageSize": 20
            },
            {
                "id": "store02",
                "title": "Gemeinden in Deutschland (Feature Layer)",
                "layerId": "gemeindelayer",
                "useIn": [
                    "omnisearch"
                ],
                "omniSearchSearchAttr": "g_name",
                "omniSearchDefaultLabel": "Enter search term...",
                "omniSearchPageSize": 20
            }
        ]
    },
    "map-init": {
        "Config": {
            "map": {
                "layers": [
                    {
                        "id": "grenzen",
                        "type": "AGS_DYNAMIC",
                        "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/MapServer",
                        "sublayers": [
                            {
                                "id": 0,
                                "title": "Gemeinden"
                            }
                        ]
                    },
                    {
                        "id": "gemeindelayer",
                        "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/FeatureServer/0",
                        "type": "AGS_FEATURE"
                    }
                ]
            }
        }
    }
}

Alternatively, the URL of the layer can be defined independently of the reference to a map configuration:

{
    "agssearch": {
        "AGSStore": [
            {
                "id": "store01",
                "title": "Gemeinden in Deutschland",
                "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/MapServer/0",
                "omniSearchSearchAttr": "g_name",
                "omniSearchDefaultLabel": "Enter search term...",
                "omniSearchPageSize": 20
            }
        ]
    }
}

The following options are available for configuring the data sources:

Name Beschreibung

omniSearchSearchAttr

Name of the attribute on which the search is performed. This must be of type String. If it is omitted, the display field of the layer is used.

omniSearchLabelAttr

Name of the attribute whose value is used for the result list. If omitted, the value of the attribute omniSearchSearchAttr is used.

omniSearchLabelString

A custom string to display the results. Several attributes can be combined.

Sample:

"${street}, ${town} (${country})" results in "Martin-Luther-King-Weg, Muenster (Germany)"

omniSearchPageSize

Number of results in the result list per page.

omniSearchDefaultLabel

Placeholder for the data source in the search dialog.

omniSearchPriority

Display order for multiple data sources. The higher the value, the higher up the data source is displayed.

omniSearchAutoActivate

If the value is set to true, this data source is selected when the app starts.

For more information about configuration, refer to the bundle documentation .

ArcGIS Locator

Required Bundle: locator-store

ArcGIS geocoding services can be used to search for addresses or POIs. The Esri World Geocoding Service is a search service that provides information for many countries . In Germany, for example, it is possible to search for addresses by house number.

By configuration, the search can be restricted to individual countries and/or categories (for example addresses, cities, POIs). By means of so-called views , a finer restriction to certain geographical areas can be made. You can offer differently configured searches or views in one app.

Name Description

title

Title of the store.

description

Description of the store.

omniSearchDefaultLabel

Placeholder for the data source in the search dialog.

url

URL to an ESRI Geolocation Service. If empty, the World Geocoding Service is used.

countryCode

Default value is an empty string. Limits the returned suggestions to values in a particular country. Supported values include the ISO 3166-1 2-digit country code or the ISO 3166-1 3-digit country code. See Esri documentation .

categories

Default value is an empty array. A place or address type that can be used to filter suggested results. See Esri documentation .

{
    "locator-store": {
        "Config": {
            "title": "Address or place search",
            "description": "Find addresses or places.",
            "omniSearchDefaultLabel": "Address or place...",
            "url": "@@locator.service.url@@",
            "countryCode": "DEU",
            "categories": [
                "City",
                "District"
            ]
        }
    }
}
For more information about configuration, refer to the bundle documentation .