wiki:Cookbook/Map/Query

Version 2 (modified by pagameba, 16 years ago) ( diff )

--

Using Map.query()

Fusion contains several widgets that allow the user to interactively select features in your map, but it is also possible to programmatically select features as well. This can be done in a couple of ways:

  • writing some server-side code that performs the query, or
  • using the query() method of the Map widget.

In this recipe, we'll look specifically at using the client side Map.query() method.

Map.query( options )

The options parameter to Map.query is an object that contains some of the following attributes:

persistent
boolean, default is true. Determines if the features selected by the query will be persistent beyond this query - i.e. they will stay on the map until the user clears the query results.
geometry
string, default is (no geometry). A Well Known Text string that defines the geometry to restrict the query to. The acceptable WKT format for geometries that work with this method are:
  • POLYGON((x y, x y, x y, ...))
  • LINESTRING(x y, x y, x y, ...)
  • POINT(x y)
maxFeatures
integer, the default is 0 (no maximum). This restricts the query to return only a certain number of results. MapGuide only at this time, although there is no reason why it couldn't be implemented for MapServer too
layers
string, default is (do not limit to specific layers). This is a comma separated list of layer names to restrict the query to, often used to limit queries a single layer.
selectionType
string, default is 'INTERSECTS'. This controls how the server interacts with the geometry property. Not sure what other selectionTypes there are, need to research this
filter
string, default is (no filter). This is an SQL WHERE clause style string (attribute = 'value', attribute <= number) that is used to limit features in a query. MapGuide only at this time. MapServer supports attribute queries but not in the same way as MapGuide - and MapServer doesn't have a way of combining both geometry and filter at this time
extendSelection
boolean, default is false. This controls whether the current query will extend the current result set or replace it. MapGuide only at this time
computedProperties
boolean, default is false. This controls whether to compute additional properties about the geometries of the features that are in the result set, including perimeter and area of polygons, lengths of lines etc.
Note: See TracWiki for help on using the wiki.