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

Can I get vl-interaction-select to use its updated condition property #111

Closed
PeterC66 opened this issue Nov 28, 2018 · 4 comments
Closed
Assignees

Comments

@PeterC66
Copy link

I am still working with vl-interaction-select, and have an issue. Thanks for your help so far. I am not sure if this is about the vl-interaction-select component itself, or a Vue reactivity issue, or just my lack of understanding.

I want to use data (actionOnClick) in a Vuex store to determine whether vl-interaction-select responds to a singleClick [actionOnClick==='select'], or pointerMove (ie hover) [actionOnClick!=='select'].

I have:-

<vl-interaction-select
  v-if="drawType == null"
  :features.sync="selectedFeatures"
  :multi="true"
  :condition="wantHover ? pointerMove : singleClick"
>

Now in a simple test (ignoring actionOnClick) I have

import { singleClick, pointerMove } from 'ol/events/condition';

computed: {
  singleClick() {
    return singleClick;
  },
  pointerMove() {
    return pointerMove;
  },
  wantHover() {
    return true;
  },

This works as I expect - the selection is by hover.

If I change it to

  wantHover() {
    return false;
  },

again it works as I expect - the selection is by single click.

Now if I introduce

import { mapState } from 'vuex';

  computed: {
    ...mapState({
      actionOnClick: state => state.mapping.actionOnClick,
    }),
    wantHover() {
      return this.actionOnClick !== 'select';
    },

again it works as I expect - because the initial value of actionOnClick is NOT 'select', the selection is by hover.

However this is where it seems odd. I have a dropdown to change the value of actionOnClick to 'select' in Vuex. This all works, and in Vue devtools I see that the condition property of vl-interaction-select has changed from pointerMove to singleClick - again as I would expect. However the selection remains as by hover not by single click. It seems as though vl-interaction-select is still using its original property value.

Can I get vl-interaction-select to use its updated property? Or have I misunderstood something?

@ghettovoice ghettovoice self-assigned this Nov 29, 2018
@ghettovoice
Copy link
Owner

ghettovoice commented Nov 29, 2018

Hello @PeterC66 ,
you right, this is related to vl-interaction-select and public interface of the ol.interaction.Select .
ol.interaction.Select doesn't allow change of the condition at the runtime.
The only way to change it is recreate interaction, I can implement this in the vl-interaction-select like it was done in the vl-style-* components.

I'll try to fix this soon

@PeterC66
Copy link
Author

Thanks. It is a relief to know I wasn't doing something wrong. No hurry for the fix, as I have plenty of other things to implement.

@ghettovoice
Copy link
Owner

I not immediately guessed how implement hidden recreation for openlayers components that doesn't provide setters for its properties. So now watching for all properties doesn't implemented everywhere in VueLayers components.

But now with the latest versions it can be added relatively easy.
I'll ping you here

@stale
Copy link

stale bot commented May 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 5, 2019
@stale stale bot closed this as completed May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants