This module is intended to contain basemap layers for deck.gl.
See the online documentation for more information.
Implementation of a subset of the Mapbox Style Specification using Deck.gl layers.
License: MIT License
This old PR (visgl/deck.gl#1003) contained a PathMarkerLayer
, which rendered symbols along a path. I might end up reimplementing this layer anyways, for e.g. text labels along roads.
If I combine multiple source layers into a single deck layer for performance reasons, then by default when you pick any line within the PathLayer
, you'd pick the entire collection. However, there must be some way for picking to pick a subset, since a GeoJSON layer and Path Layer already do this... You can add many objects but pick one
TODO
comment in a4d17bc. It's been assigned to @kylebarron because they committed the code.Use the mapbox style spec's filter!
var ff = require('@mapbox/mapbox-gl-style-spec').featureFilter;
// will match a feature with class of street_limited,
// AND an admin_level less than or equal to 3,
// that's NOT a polygon.
var filter = [
"all",
["==", "class", "street_limited"],
["<=", "admin_level", 3],
["!=", "$type", "Polygon"]
]
// will match a feature that has a class of
// wetland OR wetland_noveg.
// ["in", "class", "wetland", "wetland_noveg"]
// testFilter will be a function that returns a boolean
var testFilter = ff(filter);
// Layer feature that you're testing. Must have type
// and properties keys.
var feature = {
type: 2,
properties: {
class: "street_limited",
admin_level: 1
}
};
// will return a boolean based on whether the feature matched the filter
return testFilter({zoom: 0}, feature);
Note that to validate filter
, you'll probably need to pass the filter
keys to validateFilter
manually, because the rest of the specification won't be a valid Mapbox GL style.
I.e. if I want to snap features to tin inside this layer, if I end up also doing the mvt parsing inside this layer, see #10
TODO
comment in 5aec52a. It's been assigned to @kylebarron because they committed the code.What shared deck.gl layer attributes do you need to include, i.e.
id
And what mapbox-style-spec-like attributes?
source
source-layer
TODO
comment in fdee88a. It's been assigned to @kylebarron because they committed the code.How should layers be created from the spec?
new DeckglStyleSpecLayer({...})
Props:
Then inside renderSubLayers
I render individual layers.
How should the data process work?
PathLayer
, one SymbolLayer
, one TextLayer
(though start with the PathLayer
).I think the latter option makes more sense, so the following will pertain to that.
It's worth exploring whether you can use a portion of the Mapbox style spec, without additions within the Style JSON.
To parse expressions:
arr = [ '==', 'brunnel', 'tunnel' ]
stylespec.expression.isExpression(arr)
// true
exp = stylespec.expression.createExpression(arr)
{
result: 'success',
value: StyleExpression {
expression: Literal { type: [Object], value: false },
_warningHistory: {},
_evaluator: EvaluationContext {
globals: undefined,
feature: null,
featureState: null,
formattedSection: null,
_parseColorCache: {},
availableImages: null
},
_defaultValue: null,
_enumValues: null
}
}
Note that value
is a StyleExpression
object, which has an evaluate()
method.
Note that an expression must begin with one of these keys:
https://github.com/mapbox/mapbox-gl-js/blob/9489d7654ef9bb36a44c9b98446b84eccb98628a/src/style-spec/expression/definitions/index.js#L49-L83
Need to do a deeper dive here. This seems to be the best way to loop over properties. Look closer at the flow types for help
stylespec.visit.eachProperty(style, {paint: true}, x => console.log(x))
This could have several performance improvements:
TypedArray
s. In the current MVTLoader
, everything is parsed as regular JS objects and arrays. If you parse the MVT at the same time as you're creating binary objects to return to Deck.gl, maybe you'd be able to always use TypedArray
sdict
/Map
. Currently, loaders.gl
parses to a flat array, which I then need to loop over again when searching for features pertaining to a particular source layer. Could theoretically always work directly with the pbf, but would it take time to parse features every time you iterate over the pbf? Could be better to parse the mvt once for the layers you know you'll be looking at later.For now while developing I'll just stick with geojson features/js objects, but eventually you should support binary attributes for performance.
Keep data the same, but changing scale
with zoom might be able to simulate the same effect as zoom-dependent functions.
TODO
comment in fdee88a. It's been assigned to @kylebarron because they committed the code.TODO
comment in c4034c5. It's been assigned to @kylebarron because they committed the code.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.