Skip to content
New issue

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

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

Already on GitHub? # to your account

declutterMode and other props not available on ol-style-text? #411

Open
vincerubinetti opened this issue Feb 22, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@vincerubinetti
Copy link

vincerubinetti commented Feb 22, 2025

Describe the bug

Here's some pseudo code of what I'm working on

<template>
  <Layers.OlVectorLayer>
    <Sources.OlSourceVector ref="geometryRef" :features="features">
      <Map.OlFeature
        v-for="(feature, key) in features"
        :key="key"
        :properties="feature.getProperties()"
      >
        <!-- https://github.com/MelihAltintas/vue3-openlayers/issues/410 -->
        <Styles.OlStyle
          :key="JSON.stringify(scale.steps) + geometryOpacity"
        >
          <Styles.OlStyleStroke color="black" />
          <Styles.OlStyleFill
            :color="
              feature.get('id') === highlight
                ? getCssVar('--theme')
                : scale.getColor(
                    values?.[feature.get('id')]?.value,
                    geometryOpacity,
                  )
            "
          />
          <Styles.OlStyleText
            :text="feature.get('label')"
            font="16px 'Roboto Flex'"
            fill="black"
            :stroke="{ color: 'white', width: 2 }"
            declutterMode="none"
          />
        </Styles.OlStyle>
      </Map.OlFeature>
    </Sources.OlSourceVector>
  </Layers.OlVectorLayer>
</template>

Note the text styles. The docs for the component are missing several options from the Open Layers constructor, such as declutterMode (which I really need to turn off), keepUpright, etc.

Now looking at the demo docs page, I see I can use overrideStyleFunction, but then I'd have to more verbosely redfine everything that's within my Styles.OlStyle attributes, which imo is defeating the purpose of using the library.

Perhaps more importantly, looking at the source code, it appears like it's intended that all extraneous props are passed through to the constructor, though I could be reading it wrong:

return new Text(options);

const properties = usePropsAsObjectProperties(props);

Maybe something in that usePropsAsObjectProperties util func is preventing it from working? I've also tried different casings, e.g. declutter-mode, with no luck.

Affected version(s)

├── ol-contextmenu@5.5.0
├── ol-ext@4.0.27
├── ol@10.4.0
├── vue@3.5.13
└── vue3-openlayers@11.3.3
@vincerubinetti vincerubinetti added the bug Something isn't working label Feb 22, 2025
@vincerubinetti
Copy link
Author

Apologies, I'm not certain that the extra props are failing to be passed to the object constructor. I thought it wasn't working because text labels were disappearing on zoom out, but it turns out I really needed to set overflow to true to prevent this from happening, not declutterMode.

Instead, this issue can just be focused on adding the typescript definitions to the props so that the extra ones can be passed without complaint.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant