Comments (3)
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.
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.
Thank you both! We can close this issue now. 👍
from ol-mapbox-style.
Related Issues (20)
- Mapbox streets-v12 style trys to load invalid fonts HOT 1
- Make source available in transformRequest HOT 2
- Guessing of access token parameter may lead to bad requests HOT 1
- Requests to third-party server for fonts HOT 8
- issue with standalone example using recent versions of olms (METERS_PER_UNIT error) HOT 1
- applyBackground issue HOT 3
- line-pattern webgl HOT 3
- Provide a default URL template for fonts when 'ol:webfonts' not available HOT 1
- Issue rendering fill layers above symbol layers HOT 2
- 加载mapboxgl的样式时文本标签显示错乱 HOT 1
- Maybe a bug in stylefunction HOT 2
- Vector tile layer with MVT format clip circle style HOT 6
- Is there a possibility to use raster source with ol-mapbox-style HOT 4
- Hillshade uses incorrect resolution when determining slope angles HOT 3
- Cannot add mapbox layer if source was not referenced before HOT 6
- Refreshing symbols HOT 7
- Change attribution HOT 1
- VectorTile layers with source `minZoom` 0 not visible when view is zoomed out HOT 1
- Rendering very slow when there are many text labels HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ol-mapbox-style.