Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Type for OpenLayers layer #304

Open
mbeckem opened this issue Apr 11, 2024 · 0 comments
Open

Create Type for OpenLayers layer #304

mbeckem opened this issue Apr 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mbeckem
Copy link
Contributor

mbeckem commented Apr 11, 2024

Open Layers layer do not have a "type" attribute and thus it is not easily possible to check a layers type.

To simplify the layer type check, a new type (e.g. "WellKnownOlLayer") could be introduced. This type would represent all LayerTypes that are known to the Trails base packages.

Additionally, a helper function for getting a layers type should be introduced.

Example:

type WellKnownLayer = { "type": "group", layer: LayerGroup } | { "type": "image"; layer: ImageLayer } | { type: "unknown"; layer: OlBaseLayer };
 
function getWellKnownLayer(layer: OlBaseLayer): WellKnownLayer { 
  if (layer instanceof LayerGroup) { 
    return { type: "group"; layer };
  }
  // ... more checks
  return { type: "unknown"; layer };
}

(Maybe also think about introducing a type for Open Layer sources.)

@mbeckem mbeckem added the enhancement New feature or request label Apr 11, 2024
@mbeckem mbeckem changed the title [MapModel] Create Type for OpenLayers layer Create Type for OpenLayers layer Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant