ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
682 stars 230 forks source link

vl-style-func not working #462

Closed BlazeRed closed 2 years ago

BlazeRed commented 2 years ago

Hi, we tried to use vl-style-func to style my points like that:

<vl-layer-vector>
 <vl-source-cluster v-bind:distance="15">
  <vl-source-vector v-bind:features="featuresMap.features" />
 </vl-source-cluster>
 <vl-style-func v-bind:function="clusterStyle" />
</vl-layer-vector>
clusterStyle() {
 return (feature) => {
  return new Style({
   image: new Circle({
   fill: new Fill({ color: "#fff" }),
   stroke: new Stroke({ color: "blue", width: 1.5 }),
   radius: 10,
  }),
  text: new Text({
   text: String(feature.get("features").length),
   }),
  });
 };
},

But nothing is displayed. For context we're using vuelayers "0.12.0-rc.26". Can please someone help us understanding how to use correctly the vl-style-func component?

BlazeRed commented 2 years ago

We have also another question, we add the map based on issue #456. We encountered a strange behaviour on the displayed points:

Schermata 2021-11-19 alle 12 33 01

seems like some of them are under a map layer and is not possible to interact with them.

ghettovoice commented 2 years ago

Hello @BlazeRed ,

regarding your first question about style function:

in v0.12 vl-style-func now accepts style function instead of style function factory, so you need to adjust clusterStyle method:

clusterStyle(feature) { // take a not that method now is style function itself
    return new Style({
        image: new Circle({
            fill: new Fill({ color: "#fff" }),
            stroke: new Stroke({ color: "blue", width: 1.5 }),
            radius: 10,
        }),
        text: new Text({
            text: String(feature.get("features").length),
        }),
    });
},
ghettovoice commented 2 years ago

As for the second question: so the points on your screenshot... Are they loaded via ol-mapbox-style lib? So they in some of appended vector layer, right?

BlazeRed commented 2 years ago

Are they loaded via ol-mapbox-style lib? So they in some of appended vector layer, right?

The map is loaded via olms() of ol-mapbox-style lib. The features points are loaded via vl-source-vector. Then I think, yes they are in two different layers

ghettovoice commented 2 years ago

Ok, no I see. Try to define some :z-index=... on the vl-layer-vector(that is wrapping points vl-source-vector) more than 0. It should rise up this vector layer.

stale[bot] commented 2 years ago

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.