The styling editor lets you create a set of display rules for a map. This article covers the following topics:
- What's a display rule?
- How filters work
- How to order display rules
- How to import styles from other layers
- How to work with dense data sets
A display rule specifies the way that a map appears at a specific zoom level. Zoom level zero (0) is distant (zoomed out) zoom level 24 is close (zoomed in). You can create multiple display rules, each at a different zoom level or range of zoom levels, to change the appearance of the map as the user zooms in and out.
Within each display rule, you can specify:
- The appearance of each type of feature. For example, you can specify the color of a line, the fill color of a polygon, or the icon associated with a point.
- Filters that determine the specific features to which the style applies.
Filtering lets you match a style to the data in a vector table. For example, imagine a vector table that contains roads and contains the attribute
ROADCLASS, which denotes the importance and size of the road. By filtering on the value of
ROADCLASS, you can create one display rule for national roads, another for regional roads, and yet another for small local roads or paths.
By using multiple filters, you can specify a more complex set of criteria. For example, suppose you are using a data souce that consists of points that represent populated places. Attributes include population 1950 and population in 2000, and you want to highlight places whose population grew from less than 1 million to over 5 million in those fifty years. You'd choose a specific icon and set two filters:
- One filter matches places whose population is greater than 5 million
- One filter matches places whose population in 1950 was less than 1 million
The display rule applies to a vector only if all the filters match, so only the appropriate features will have the icon.
You don’t have to style all the data, because the default style applies to all features that aren't filtered. For example, if you want to highlight key features by showing them in red but let all other features appear in green, make the default color green and then set a filter to select the key features and color them red.
If there are multiple rules, Maps Engine applies them in the same order that they appear in the style editor. The first rule is applied first, then the next is applied, and so on. Each display rule applies only to the vectors that didn't match the previous rule. Therefore, you'll need to order rules to start with the most specific rule and move down to the least specific rule.
Suppose you have a data set that contains cities with populations of 5 million or greater. You want the map to distinguish three categories of cities: population greater than 5 million, greater than 10 million, and greater than 15 million. You'd create three display rules, each with its own icon, and order them as follows:
- The rule for cities with population greater than 15 million is first
- The rule for cities with populations greater than 10 million is second
- The rule for cities with populations greater than 5 million is last
The order is important. If you reverse the order, the same icon will apply to all cities because Maps Engine will process the first filter and all cities will match the "greater than 5 million" filter.
To streamline the styling process, copy another layer's style! When you first start to edit the style of a layer that's never been styled, you have the option to import display rules. The option is present only until you create a style for that layer by saving display rules.
If you choose to import styles, Maps Engine lists some layers from which you can import styles. The layers need not be published or even styled.
There might be some mismatches between the schema of the data in the source layer and the schema of the data in the target layer. If attributes are different in the two data sources, filters may be imperfectly mapped, so you'll need to make some fixes manually.
Here are two scenarios in which Maps Engine finds mismatched filters.
|Symptom||Reason||What to do|
|The attribute field is empty.||The original style has filters on attributes that aren't present in the current data.||Remap the filter to an attribute in the current data. You can remap the filter until you click APPLY. If you click APPLY, Maps Engine saves the imported display rules, and if you haven't yet mapped the filter so to include an attribute, Maps Engine discards it.|
|The operator field is empty.||The original style has a filter on an attribute and the attribute name is present in the current data, but the data associated with that attribute has a different type. For example, the data type might be text instead of numeric.||Remap the filter so that it uses an appropriate operator for the current data type.|
If a layer contains a dense feature set, carefully consider the zoom level at which the features should appear. There's a limit on the number of features shown in a viewport, so when a dense layer covers a large area, some features might not appear.
For such a layer, view the styled layer at various zoom levels to confirm that the features appear correctly. You might need to adjust the display rules to show the features only when the map is sufficiently zoomed in.