Description
In order to facilitate map manipulation such as zooming to features or groups of features, among other at present unknown uses, we should define a public (therefore proposed DOM standard) primitive API method for the <mapml-viewer> (etc).
This could be a fitExtent(extent)
method.
Its required extent
parameter would match the type that is currently returned by <layer->.extent
property, currently a JSON object. If that's not possible in DOM, we could re-think the signature to reduce the inputs to JavaScript primitive types, but for brevity here, I'm suggesting an extent
object type.
This method could be used to obtain the zoom
parameter required for the <mapml-viewer>.zoomTo(latitude, longitude, zoom)
method, from an extent that they wanted to zoom to, for example the extent of a feature or group of features (the position would presumably be calculated from an extent by averaging its min/max coordinates).
Information that is needed to do this calculation, apart from the extent
itself, is the size of the current map viewport, in projected pixels or other projected units. Also, the set of available zoom levels associated to the TCRS of the map is required.
I think a simple approach to what this function would do is implemented in the GeoServer MapML extension (the viewport is guessed by the server to be some standard screen size). In that code, the method is located as a method of the TCRS, however TCRS is not exposed in MapML, except as an attribute value, so the <mapml-viewer> seems the correct place to put the method.