To zoom a map to a set of map features, you should create an NMapZoomToFeatures filter by passing an NMapFeatureFilter to its constructor. If you want to filter map features based on the value of one or more of their attributes, you should use the NMapFeatureAttributesFilter. It is similar to CSS selectors and accepts two types of selector parts - conditions and combinators (OR and AND). The Add method of the filter adds a condition and an AND combinator after it by default. You can use its 2 parameter overload to specify a combinator explicitely.
The following code example demonstrates how to create and configure a map zoom to features object:
Zoom to map features |
Copy Code
|
---|---|
NMapShapeFieldsFilter filter = new NMapFeatureAttributesFilter(); filter.Add(new NMapShapeFilterCondition("Sales", MapConditionOperator.Equals, 67), NMapShapeFilterCombinator.Or); filter.Add(new NMapShapeFilterCondition("Sales", MapConditionOperator.GreaterThan, 106)); filter.Add(new NMapShapeFilterCondition("Sales", MapConditionOperator.LessThan, 107)); mapImporter.MapZoom = new NMapZoomToFeatures(filter); |
This map zoom object zooms the map to all map features whose "Sales" attribute value is equal to 67 or is between 106 and 107.