How-to add a layer search¶

Search operations are only supported on vector, geojson, ags-vector, wfs, and mapserver-wfs map-source types.

You can also add search operations to ags, wms, and mapserver mapsources using the query-as technique.

Add a supported vector map-source¶

This how-to references the firestations source and fire_stations layer. For more information on setting those up in your local demo, read the:doc:./add-a-layer guide. This example creates a WFS-source for the Firestations layer.

Add the following to mapbook.xml:

<map-source name="firestations-wfs" type="mapserver-wfs">
    <file>./demo/firestations/firestations.map</file>
    <param name="typename" value="ms:fire_stations" />
    <layer name="fire_stations" selectable="true" title="Firestations">
        <template name="search"><![CDATA[
        <div class="result-item">
            <div class="result-title">
            Firestation
            </div>
            <b>Station City:</b> {{ properties.Dak_GIS__4 }}<br>
            <b>Station Number:</b> {{ properties.Dak_GIS__5 }}<br>
        <div>
        ]]></template>
    </layer>
</map-source>

Configure a search service¶

In app.js, a new search service needs configured for that layer:

// Add a search service
app.registerService('search-firestations', SearchService, {
    // search only the firestations-wfs/fire_stations layer.
    searchLayers: ['firestations-wfs/fire_stations'],
    // Dak_GIS__4 stores the name of the Firestation's city.
    fields: [
        {type: 'text', label: 'Station city', name: 'Dak_GIS__4'}
    ]
});

Add the search service to the toolbar¶

In the mapbook.xml:

  1. Find the <toolbar> element.

  2. Inside the <toolbar> element, add the follow entry for the new search service:

    <tool name="search-firestations" title="Search Firestations" type="service"/>
    

GeoMoose

Navigation

  • Introduction
  • Quickstarts
  • GeoMoose Workshop
  • Customization and Concepts
  • How-Tos
    • How-to add a langauge
    • How-to add a layer
    • How-to add a Plugin
    • How-to Add Attribution to a layer
    • How-to add decluttering to a vector layer
    • How-to add a GeoJSON file
    • How-to add a Grid to Search and Identify
    • How-to add Identify
    • How-to add a layer search
    • How-to let the user choose a search layer
    • How-to add Select to a layer
    • Vector Editing Introduction
    • Vector Editing Tutorial
    • Using Vector Editing
    • How-to Add a Zoom-Level Jumper
    • How-to add an AGS Tile Layer
    • How-to add Bing layers
    • How-to change the default buffer units
    • How-to Change the Empty Super Tab Message
    • Changing the selection and highlight colors
    • How-to Change the Loading Indicator in the Super Tab
    • How-to add a multi-field complex search
    • How-to configure the Jump to Extent Drop Down
    • Configure Number of Buffer-able Features
    • How-to configure the Measure tool
    • Configuring the Scale Line
    • How-to configure a search to require a field to be completed
    • How-to Configure “or” type Search
    • How-to configure to select from list
    • How-to configure select options
    • How-to configure the Coordinate Display
    • How-to customize result tools
    • How-to customize tabs
    • How-to add a disclaimer
    • How-to Exclude a Layer From Highlight
    • How-to use GeoJSON/WFS
    • How-to Hide the Search in the Catalog
    • How-to create a custom print layout
    • How-to display a raster layer and query as a vector layer
    • How-to limit the Extent, Min and Max Zoom of the Map
    • How-to start a service (even at startup)
    • How-to Start at Extent
    • How-to style the header
    • How-to style the toolbar
  • Developer Documentation

Related Topics

  • Documentation overview
    • How-Tos
      • Previous: How-to add Identify
      • Next: How-to let the user choose a search layer

Quick search

©. | Powered by Sphinx 7.2.6 & Alabaster 0.7.12 | Page source