Map projection media queries

Maps come in many projections that serve different purposes. Web maps have the ability to change projection based on criteria established by the map author. For example, some maps change projection as you zoom out, to give you the impression of altitude from the curved surface of the globe. In other cases, changing projections is not an aesthetic consideration but a scientific or technical one, because any transformation of the surface of the globe to a plane imposes distortion on the depicted features. The nature of the distortion can be chosen by choosing a projection with different or appropriate qualities.

Changing projection can be technically challenging for web maps, because not all data sources are created in all the projections that might be needed for a complete web mapping application.

The buttons above set the <mapml-viewer>'s projection (attribute) to "Web Mercator" (OSMTILE) or Lambert Conformal Conic (CBMTILE). Normally, if a child <map-layer> is not capable of presenting in a different projection, it will become disabled in the layer control and not rendered on the map. In this experiment, instead of allowing the map to become inert when the projection changes, the author has registered a map media query on the map's projection, and each time it changes, an event handler is notified by the registered query, and the handler procedurally changes the map's data source (<map-layer>), because the server-based image tile collections for the two projections typically have different URL values and indeed, quite different structures.

Making projection and data source changes available through a button in this example is contrived to demonstrate this capability. However, a similar approach could be taken in real-life applications, in response to user-induced changes in map state (panning or zooming or linking), changing projection and data sources in cascading responses to queried map state changes.