Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Filter

JMap.Map.Filter

JMap offer the ability to filter the features that are rendered on the map.

We can apply filter on attributes values, or a spatial filter.

Index

Functions

applyAttributeValueBetween

  • applyAttributeValueBetween(layerId: JId, attributeId: string, start: any, end: any): string
  • JMap.Map.Filter.applyAttributeValueBetween

    Render only layer's features that has attributeId having value between start and end attributes, including equals values.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render only features having "level" greater or equals to 2 and lower or equals to 10 for layer 4
    JMap.Map.Filter.applyAttributeValueBetween(4, "level", 2, 10)

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • start: any

      The max value

    • end: any

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueEqualTo

  • applyAttributeValueEqualTo(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueEqualTo

    Render only layer's features that has attributeId having value equals to attributeValue

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "name" equals to "Aquarius" for layer 4
    JMap.Map.Filter.applyAttributeValueEqualTo(4, "name", "Aquarius")

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueGreaterOrEqualsTo

  • applyAttributeValueGreaterOrEqualsTo(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueGreaterOrEqualsTo

    Render only layer's features that has attributeId having value greater or equals to attributeValue.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" greater or equals to 2 for layer 4
    JMap.Map.Filter.applyAttributeValueGreaterOrEqualsTo(4, "level", 2)

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueGreaterThan

  • applyAttributeValueGreaterThan(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueGreaterThan

    Render only layer's features that has attributeId having value strictly greater to attributeValue.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" strictly greater than 2 for layer 4
    JMap.Map.Filter.applyAttributeValueGreaterThan(4, "level", 2)

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueIn

  • applyAttributeValueIn(layerId: JId, attributeId: string, attributeValues: any[]): string
  • JMap.Map.Filter.applyAttributeValueIn

    Render only layer's features that has attributeId having value matching any values in attributeValues.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" equals to 4 or 5, for layer 4
    JMap.Map.Filter.applyAttributeValueIn(4, "level", [ 4, 5 ])

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValues: any[]

      The attribute values to match

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueLowerOrEqualsTo

  • applyAttributeValueLowerOrEqualsTo(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueLowerOrEqualsTo

    Render only layer's features that has attributeId having value lower or equals to attributeValue.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" lower or equals to 5 for layer 4
    JMap.Map.Filter.applyAttributeValueLowerOrEqualsTo(4, "level", 5)

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueLowerThan

  • applyAttributeValueLowerThan(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueLowerThan

    Render only layer's features that has attributeId having value strictly lower to attributeValue.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" strictly lower to 5 for layer 4
    JMap.Map.Filter.applyAttributeValueLowerThan(4, "level", 5)

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueNotEqualTo

  • applyAttributeValueNotEqualTo(layerId: JId, attributeId: string, attributeValue: any): string
  • JMap.Map.Filter.applyAttributeValueNotEqualTo

    Render only layer's features that has attributeId not having value equals to attributeValue

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will hide features having "name" equals "Aquarius" for layer 4
    JMap.Map.Filter.applyAttributeValueNotEqualTo(4, "name", "Aquarius")

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValue: any

      The attribute value

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyAttributeValueNotIn

  • applyAttributeValueNotIn(layerId: JId, attributeId: string, attributeValues: any[]): string
  • JMap.Map.Filter.applyAttributeValueNotIn

    Render only layer's features that has attributeId having value not matching any values in attributeValues.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render features having "level" not equals to 4 or 5, for layer 4
    JMap.Map.Filter.applyAttributeValueNotIn(4, "level", [ 4, 5 ])

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    • attributeValues: any[]

      The attribute values to match

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyHasAttribute

  • applyHasAttribute(layerId: JId, attributeId: string): string
  • JMap.Map.Filter.applyHasAttribute

    Render only layer's features that has the attribute defined in their properties. If the feature attribute is defined but its value is undefined, the feature will be rendered.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will render only features having attribute "name" for layer 4
    JMap.Map.Filter.applyHasAttribute(4, "name")

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applyHasNotAttribute

  • applyHasNotAttribute(layerId: JId, attributeId: string): string
  • JMap.Map.Filter.applyHasNotAttribute

    Render only layer's features that hasn't the attribute defined in their properties. If the property is defined but value is undefined, the feature will not be rendered.

    Only one attribute filter can be set for a specific layer and attributeId at the same time.

    throws

    Error if layer or attribute is not found

    example
    
    // Will hide features having attribute "name" for layer 4
    JMap.Map.Filter.applyHasNotAttribute(4, "name")

    Parameters

    • layerId: JId

      The JMap layer id

    • attributeId: string

      The JMap attribute id

    Returns string

    The filter id. By example for layer 4 and attribute 'on_off' => "attribute-4-on_off"

applySpatial

  • JMap.Map.Filter.applySpatial

    Render only layer's features that intersect the filterGeometry area.

    Only one spatial filter can be set for a specific layer at the same time.

    throws

    Error if layer is not found, or filterGeometry format is not good

    example
    
    // Will render features that intersect the circle of radius 500 (in km) centered at location x=20 and y=10.
    JMap.Map.Filter.applySpatial(4, { radius: 500, center: { x: 20, y: 10 }})
    
    // Will render features that intersect the polygon (in this case a square)
    JMap.Map.Filter.applySpatial(4, [ [ 20.44, 10.32 ], [ 20.44, 78.44 ], [ 40.56, 78.44 ], [ 40.56, 10.32 ], [ 20.44, 10.32 ] ])

    Parameters

    • layerId: JId

      The JMap layer id

    • filterGeometry: JPolygon | JCircle

      The geometry that is the area to search. Can be a circle or a polygon.

    Returns string

    The filter id. By example for layer 4 => "spatial-4"

removeAllFilters

  • removeAllFilters(layerId: JId): void
  • JMap.Map.Filter.removeAllFilters

    Remove all spatial and attributes filters for layer.

    example
    
    // Remove all filters (spatial + attribute) for layer 3
    JMap.Map.Filter.removeAllFilters(3)

    Parameters

    • layerId: JId

      The JMap layer id

    Returns void

removeByFilterId

  • removeByFilterId(filterId: string): void
  • JMap.Map.Filter.removeByFilterId

    Remove the filter on the map following the filter id passed in parameter.

    example
    
    // Remove spatial filter on layer 3
    JMap.Map.Filter.removeByFilterId("spatial-3")
    
    // Remove attribute filter on attribute id="on_off", on layer 4
    JMap.Map.Filter.removeByFilterId("attribute-4-on_off")

    Parameters

    • filterId: string

      The filter id. The one you get when you call a filter method that starts with apply.

    Returns void