Skip to content

Questions about ol-interaction-modify compnent #421

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

Open
iboates opened this issue Mar 31, 2025 · 2 comments
Open

Questions about ol-interaction-modify compnent #421

iboates opened this issue Mar 31, 2025 · 2 comments

Comments

@iboates
Copy link

iboates commented Mar 31, 2025

I have a vector layer of features that I can add to and remove from. I want to be able to modify the geometry, but I can't figure out how to specify it.

  <!-- Wind farm site features layer -->
  <ol-vector-layer>

    <ol-source-vector :projection="projection" ref="vectorLayerTemplateRef">
      <ol-feature
        v-for="(windFarmSiteFeature, index) in windFarmSiteFeatures"
        :key="index"
        :properties="windFarmSiteFeature.properties"
        :ref="'windFarmOlFeature_' + windFarmSiteFeature.properties.windFarmSiteId"
      >
        <ol-geom-polygon :coordinates="windFarmSiteFeature.geometry.coordinates" />
      </ol-feature>
      <ol-interaction-modify />
    </ol-source-vector>

    <!-- Doesn't work -->
    <!-- <ol-interaction-modify
      :source="vectorLayerTemplateRef"
    /> -->

    <ol-style>
      <ol-style-stroke color="blue" :width="2"></ol-style-stroke>
      <ol-style-fill color="rgba(255,255,255,0.5)"></ol-style-fill>
    </ol-style>
  </ol-vector-layer>

  <!-- Doesn't work -->
  <!-- <ol-interaction-modify
    :source="vectorLayerTemplateRef"
  /> -->

The ones marked with <!-- Doesn't work -_> just crash the application.

I have it placed inside the ol-source-vector component, but I still get this error in the console:

[Vue3-OpenLayers Error] OlInteractionModify: Modify interactions needs either a source or features to work.
      Please provide either the props 'source' or 'feature' or use the component with an '<OlSourceVector>' component.

I don't understand how this is supposed to work, can somebody please provide me with an example of how you are supposed to actually link this to the ol-source-vector component?

@d-koppenhagen
Copy link
Collaborator

The VectorLayer is exposed as vectorLayer. So I think it should work once you change the access to:

<ol-interaction-modify
    :source="vectorLayerTemplateRef.vectorLayer"
  />

@iboates
Copy link
Author

iboates commented Apr 1, 2025

Thanks for the reply, but it is still not working. Whether I put it inside the ol-source-vector or not, it seems to crash:

  <!-- Wind farm site features layer -->
  <ol-vector-layer>

    <ol-source-vector :projection="projection" ref="vectorLayerTemplateRef">
      <ol-feature
        v-for="(windFarmSiteFeature, index) in windFarmSiteFeatures"
        :key="index"
        :properties="windFarmSiteFeature.properties"
      >
        <ol-geom-polygon :coordinates="windFarmSiteFeature.geometry.coordinates" />
      </ol-feature>
      <ol-interaction-modify
        :source="vectorLayerTemplateRef.vectorLayer"
      />
    </ol-source-vector>
      <!-- Doesn't work -->
      <!-- <ol-interaction-modify
        :source="vectorLayerTemplateRef.vectorLayer"
      /> -->
    <ol-style>
      <ol-style-stroke color="blue" :width="2"></ol-style-stroke>
      <ol-style-fill color="rgba(255,255,255,0.5)"></ol-style-fill>
    </ol-style>
  </ol-vector-layer>

  <!-- Doesn't work -->
  <!-- <ol-interaction-modify
    :source="vectorLayerTemplateRef.vectorLayer"
  /> -->

It seems that it is because it's not defined:

Image

Sorry, I'm not that experienced with Vue. I am aware of the lifecycle but it seems to me like I shouldn't have to do any onMounted() hackery to make this work. Further down, I get a recursion error, but I think that might just be a cascading failure from the first one:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants