7  REST for Class Layers

While a simple layer supports only two classes of geometries (those included in the layer and those that are not), a class layer enables the categorization of features into multiple classes that each represent different values for a selected property. The areas falling into the different classes are distinguished from each other by varying the display characteristics (e.g. color, shading, or opacity) defined for each class. The result is that the display of each feature's geometry depends on that feature's class.

One example of how classes work is the way the U.S. Census Bureau classifies places, which may be cities, towns, or CDP (concentrations of population referred to as "census-designated places"). The following steps illustrate how to map these three types of places as classes in a class layer:

1.  Start with the host, version, API key, and endpoint:

http://query.mapfluence.com/2.0/MFDOCS/map

2.  Add the layer definition, which means specifying the values of the required layer properties, separating each property value pair with a pipe:
- mode=class: the layer type, in this case class.
- select=umi.us_census00.place.place_type: the source of the attribute by which the geometries will be classified, in this case an attribute table classifying places by type (city, town, or CDP).
- from=umi.us_census00.place_geometry: the source of the geometries that will be overlaid, which is the geometry table in the Mapfluence dataset covering U.S. places.
- date=2009-01-01T08:00:00Z: a date, which is used to filter the results using the date attribute in the specified geometry table (the from property) and attribute table (the select property).
- values=city,town,CDP: a list of attribute values that are to be included in the map, in this case the types (classes) of place.
- border=000000_1.3: the color and line weight of the border, which shows the boundaries between geometries.
- styles=ff0000, 0000ff, 00ff00: a list of colors that will be used to render the geometry associated with the value at the same index in the values list (e.g. ff0000 for cities, 00ff00 for towns, 0000ff for CDPs). These colors could alternatively be expressed as valid HTML color names (red, blue, green).
- opacity=0.4: the overall opacity of the layer. This is an alternative to adding an alpha channel specification to the end of each color in the styles property.
Note: In a class layer, styles is plural.

/mode=class|select=umi.us_census00.place.place_type|from=umi.us_census00.place_geometry|date=2009-01-01T08:00:00Z|values=city,town,CDP|border=000000_1.3|styles=ff0000,0000ff,00ff00|opacity=0.4

3.  Add the base map code (in this case for Bing Maps) after the layer definition:

/b

4.  Add a query string after the base map code to specify the map's centerpoint, size, and zoom:

/?lat=37.6&lng=-122.2&width=640&height=480&zoom=10

5.  Put it all together and you have the complete REST path for the map:

http://query.mapfluence.com/2.0/MFDOCS/map/mode=class|select=umi.us_census00.place.place_type|from=umi.us_census00.place_geometry|date=2009-01-01T08:00:00Z|values=city,town,CDP|border=000000_1.3|styles=ff0000,0000ff,00ff00|opacity=0.4/b/?lat=37.9&lng=-122.2&width=640&height=480&zoom=10

Here's an excerpt of the map, showing the different classes of place types, that is returned from the above URL (to see the full map in a new window, click here):


Note: For complete details on the purpose and valid values of class layer properties, both required and optional, refer to the Class Layer page of the Mapfluence REST API Reference at http://developer.urbanmapping.com/docs/mapfluence/rest/2.0/reference/tile/layer/Class.

Top