B.3.1 Pre-Defined Mouse-Click Control Functions
MapViewer provides functions to enable and disable theme feature, rectangle, and polygon selection in SVG maps. It also provides functions to get information about selections and to toggle the selection status on and off. The functions for customizing mouse-click event control on an SVG map include the following:
enableFeatureSelect()
enables theme feature selection, anddisableFeatureSelect()
disables theme feature selection.Theme feature selection can be enabled if the
selectable_in_svg
attribute in the<theme>
element isTRUE
either in the map request (see theme Element) or in the base map (see Base Maps) definition. If the theme is selectable and theme feature selection is enabled, each feature of the theme displayed on the SVG map can be selected by clicking on it. If the feature is selected, its color is changed and its ID (rowid by default) is recorded. Clicking on an already selected feature deselects the feature. The list of IDs of all selected features can be obtained by calling thegetSelectedIdList()
function, described in this section.When theme feature selection is enabled, polygon selection and rectangle selection are automatically disabled.
enablePolygonSelect()
enables polygon selection, anddisablePolygonSelect()
disables polygon selection.If polygon selection is enabled, a polygon selection area can be defined by clicking and moving the mouse on the SVG map. Each click creates a shape point for the polygon. The coordinates of the polygon are recorded, and can be obtained by calling the getSelectPolygon() function, described in this section.
When polygon selection is enabled, theme feature selection and rectangle selection are automatically disabled.
enableRectangleSelect()
enables rectangle selection, anddisableRectangleSelect()
disables rectangle selection.If rectangle selection is enabled, a rectangular selection window can be defined by clicking and dragging the mouse on the SVG map. The coordinates of the rectangle are recorded, and can be obtained by calling the
getSelectRectangle()
function, described in this section.When rectangle selection is enabled, theme feature selection and polygon selection are automatically disabled.
getInfo(theme, key)
returns the informational note or tip string of the feature identified by theme name and key.getSelectedIdList(theme)
returns an array of all feature IDs that are selected on the SVG map.getSelectPolygon()
returns an array of the coordinates of all shape points of the selection polygon, using the coordinate system associated with the original user data.getSelectRectangle()
returns an array of the coordinates of the upper-left corner and the lower-right corner of the selection rectangle, using the coordinate system associated with the original user data.selectFeature(theme, key)
toggles the selection status of a feature (identified by its key value) in a specified theme.setSelectPolygon(poly)
sets the coordinates of all shape points of the selection polygon, using the coordinate system associated with the original user data. The coordinates are stored in the array poly. Calling this function afterenablePolygonSelect()
draws a polygon on the SVG map.setSelectRectangle(rect)
sets the coordinates of the upper-left corner and the lower-right corner of the selection rectangle, using the coordinate system associated with the original user data. The coordinates are stored in the array rect. Calling this function afterenableRectangleSelect()
draws a rectangle on the SVG map.
Parent topic: Mouse-Click Event Control Functions