This example documents how you can select a number of objects and then zoom to the extent of the selection.
What basically happens is we :
zoomToObjects() - zooms to objects with attribute OIDN set to 5681 or 5690.
var ofm; this.zoomToExtent = function() { ofm.zoomToExtent(); }
We execute the zoomToExtent() function.
We use a custom startup operation to make the selection :
var ofm; this.zoomToObjects = function() { var layer = ofm.getSelectionLayer(); var margin = 10; var operation = "\ <Operations>\ <SelectObjects>\ <SelectionGroupName>FocusSelection</SelectionGroupName>\ <DataSetName>"+ layer +"</DataSetName>\ <Restriction>\ <ModelId>1</ModelId>\ <Restriction>\ <AttributeSetName>Attributes</AttributeSetName>\ <AttributeName>OIDN</AttributeName>\ <AllowedValue>5681,5690</AllowedValue>\ <PatternSearch>false</PatternSearch>\ </Restriction>\ </Restriction>\ <AllowedValueSeparator>,</AllowedValueSeparator>\ </SelectObjects>\ <ClearFocus/>\ <AddSelectionToFocus>\ <SelectionGroupName>FocusSelection</SelectionGroupName>\ </AddSelectionToFocus>\ <GetFocus>\ <Margin>"+ margin +"</Margin>\ </GetFocus>\ </Operations>"; ofm.runPlainStartupOperation(operation); }
We execute the following operations :
All these operations are executed as a “startup operation” which implies the following :
The attribute value may contain a unix-style wildcard using filename expansion – also known as “globbing”.
By adding the <PatternSearch>false</PatternSearch> tag of the <Restriction> element, you can use wildcards in your attribute values. Example : [!-]* would match any string not starting with '-'.