Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Query

JMap.Application.Query

You can manage everything related to query here.

Index

Functions

activateQuery

  • activateQuery(groupId: JId, queryId: string): void
  • JMap.Application.Query.activateQuery

    Activates a query by id and group id.

    It displays the query form (replacing the list of queries) in the query panel.

    example
    
    // activate query id=43 on group id=23
    JMap.Application.Print.activateQuery(23, 43)

    Parameters

    • groupId: JId

      the query group id

    • queryId: string

      the query id

    Returns void

clearDefaultData

  • clearDefaultData(): void
  • JMap.Application.Query.clearDefaultData

    Resets the current query form data.

    If there is no active form, does nothing.

    example
    
    // clear the current query form data
    JMap.Application.Print.clearDefaultData()

    Returns void

deactivateQuery

  • deactivateQuery(): void
  • JMap.Application.Query.deactivateQuery

    Deactivatea the current query. If no query is active, does nothing.

    If a query form is active (= its form is displayed), hidea it and returns to the query list.

    example
    
    // if a query form is displayed, hide it and return to the query list.
    JMap.Application.Print.deactivateQuery()

    Returns void

displayInDialog

  • displayInDialog(isVisibleInDialog: boolean): void
  • JMap.Application.Query.displayInDialog

    By default, the query form is displayed in the left panel with a simple layout, one field per line.

    But it is possible to display it in a modal window, with the layout defined in the project.

    throws

    if isVisibleInDialog is not a boolean

    example
    
    // display the current form in a modal window
    JMap.Application.Print.displayInDialog(true)
    
    // display the current form in the left panel
    JMap.Application.Print.displayInDialog(false)

    Parameters

    • isVisibleInDialog: boolean

      true in modal window, false in left panel

    Returns void

getDefaultData

  • getDefaultData(): object
  • JMap.Application.Query.getDefaultData

    Returns the current query form data.

    If there is no active form, warns in the console and returns an empty object {}.

    example
    
    // returns the current query form data
    JMap.Application.Print.getDefaultData()

    Returns object

    • [id: string]: any

processQuery

  • processQuery(values: any): Promise<Feature[]>
  • JMap.Application.Query.processQuery

    Processes the active query form with the given values.

    Throws if no query is active.

    Resolves only if some features are found.

    If features are found, makes the layer selectable and visible if needed, then selects and zooms on found features.

    If no feature is found, the Promise rejects with a human readable error in the current user's locale.

    throws

    if no query is active

    example
    
    // display the current form in a modal window
    JMap.Application.Print
      .processQuery({
       $param1: "black",
       $param2: "white"
      })
      .then(features => console.info(`Found ${features.length} feature(s)`, features))
      .catch(error => {
        // pass here if no features are found, or other error
        // thrown error is a readable error using the user locale
        console.error(error)
      })

    Parameters

    • values: any

    Returns Promise<Feature[]>

setDefaultData

  • setDefaultData(values: any): void
  • JMap.Application.Query.setDefaultData

    Sets active query form data. If there is no active form, this function throws.

    throws

    if no query is active

    example
    
    // set the current query form data
    JMap.Application.Print.setDefaultData({
     $param1: "black",
     $param2: "white"
    })

    Parameters

    • values: any

      the form data, depends on the form

    Returns void