Giter VIP home page Giter VIP logo

Comments (3)

mike-000 avatar mike-000 commented on June 28, 2024

Style objects are returned by style functions and will differ depending on the properties of the feature (most notably for label text) and resolution, so it would be better to set the function as the feature style. But if you must have style objects (e.g. you want to set them on features which do not have the same properties as the original feature) you can obtain them for a specific original feature and resolution

const layer = new VectorLayer();
applyStyle(layer, glStyle).then(() => {
  const styleFunction = layer.getStyleFunction();
  const featureStyle = styleFunction(feature, resolution);
  // now do something with featureStyle
});

from ol-mapbox-style.

ahocevar avatar ahocevar commented on June 28, 2024

I'd recommend against feature styles. Instead, I'd set the layer property of each feature, which will be used as source-layer property in the Mapbox layer style. Then just use the style function and apply it to each layer you want to render.

Example:

feature.set('layer', 'mylayer1');

for the feature, and for the style layer:

"layers": [{
  "id": "layer1",
  "source": "mysource",
  "source-layer": "mylayer1"
}]

If you want to only style a few individual features differently, you can use feature-state.

from ol-mapbox-style.

cristianmadularu avatar cristianmadularu commented on June 28, 2024

Thank you both! We can close this issue now. 👍

from ol-mapbox-style.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.