createViewFromLayer() ​
createViewFromLayer(
layer):Promise<MapContextView|null>
Creates a view from a layer by extracting its geographic extent. The returned extent is always expressed in EPSG:4326 (longitude/latitude) coordinates.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
layer | MapContextLayer | The map context layer to extract the extent from |
Returns ​
Promise<MapContextView | null>
A Promise resolving to a ViewByExtent object, or null if the extent cannot be determined
Throws ​
If the layer type is not supported
Example ​
typescript
const wmsLayer: MapContextLayerWms = {
type: 'wms',
url: 'https://example.com/wms',
name: 'myLayer'
};
const view = await createViewFromLayer(wmsLayer);
if (view) {
console.log('Extent:', view.extent); // [minX, minY, maxX, maxY] in EPSG:4326
}