Add a read-only <layer> extent property
Edit: Change "bounds" to "extent", with associated implications. "bounds" is Leaflet pixel coordinate system-specific; "extent" fits the concept of TCRS, since a location may be expressed in any of the subordinate coordinate reference systems. The terminology associated to extent becomes less confusing, since the position of a location may be described as "top-left" (etc), which doesn't change relative to the page layout (user), whereas min and max are not always in the same position relative to the page layout, depending on which subordinate coordinate reference system is being reported i.e. in the tcrs pixel-based system, y is positive down the page; in the gcrs or pcrs systems latitude and northing are positive up the page, respectively.
In Testbed 16, it's been asked that the <layer> element provide a method for accessing the extent of its content. This information can be aggregated from layer content and used internally and externally.
The idea of this issue is to provide an API by which JavaScript clients can access the extent of the layer, without having to calculate themselves. For <layer> elements that are created with a <layer src="..."></layer> attribute referring to server content, script won't be able to calculate bounds, because the content should not be accessible via the DOM.
So, having the client be able to access the extent of the layer should be provided by an API. The proposal here is to provide this via a .extent property.
Further requirements to be defined in the comments of this issue, or by reference, include:
- what is the object structure that will be returned, and what do its values mean
- in what coordinate system are the returned extent to be interpreted
- Web IDL of the property
We propose to extend the web-map-custom-element implementation of <layer-> to add a extent property, to see how this might work and validate the need.
@ahmadayubi can you comment on this issue? I was thinking that a bounds property, not a method, would be the correct way to expose the bounds of a <layer>.bounds
Also, what should the bounds be if there is no content or src attribute, or the layer encountered an error?
For <layer> elements it would make sense that the bounds would just be a property rather than a method since its static and set once, but the <map> element would need to be a method since layers can be unselected, changing the bounds of the map. However having <layer>.bounds and <map>.bounds() might introduce a little confusion/inconsistency.
As for bounds in the case of missing content (i.e. not having meta elements setting the zoom bounds), I would say the bounds would be the bounds of the map projection. If a src is missing I would expect the layer element to return undefined since it wouldn't be rendering anything on the map, same goes for error.
However having
<layer>.boundsand<map>.bounds()might introduce a little confusion/inconsistency.
Maybe we should leave the map bounds calculation up to script, which could apply whatever logic it likes in aggregating the bounds of constituent layers? This would be left to progressive enhancement, i.e. don't ask of the platform what can/should be done by script.
I would say the bounds would be the bounds of the map projection
+1
If a src is missing I would expect the layer element to return undefined since it wouldn't be rendering anything on the map, same goes for error.
Why not the bounds of the map projection?
Other @Maps4HTML/contributors can enter opinions below :-)
For discussion, if need be, by readers of this specification.
We decided to implement the <layer>.extent property based on the union of extents of templates, excluding the extent of a query template, should it exist in the layer. The thinking is that although the extent of the query template might extend beyond that of the layer's contents, it doesn't participate in the visualization of the layer, so we excluded the inputs associated to the link@rel=query URL template.