Comments (4)
Hi,
It's because layers are not always tilelayers:
export type TiledLayer<O extends TiledMapType> = TiledLayerTilelayer | TiledLayerObjectgroup<O> | TiledLayerImagelayer | TiledLayerGroup;
So in your case you have to check if current layer is a tilelayer, then you can manipulate its data
:
map.layers.forEach(layer => {
if(layer.type === 'tilelayer') {
pako.inflate(layer.data);
}
});
This said, I see that your data is string
, but my typings expect number[]
.
What version of Tiled did you use to generate your file ?
Ok I checked Tiled doc, seems that there is changes in props (or I just forgot them 🙈 ).
So I see two changes to do:
- in TiledLayerTilelayer,
data: string | number[];
- in TiledMapAbstract, add
compressionlevel: number;
I hope finding some time to make changes & also check others forgotten props. If you can make a PR for that it would be great 😄
from tiled-types.
I just released a new version with all fixed, consider upgrading to 1.2.1
.
For tilelayer typing consider doing one of these solutions:
// you have only tilelayers, no need to check them
const tilelayers = map.layers as TiledLayerTilelayer[];
tilelayers.layers.forEach(layer => {
pako.inflate(layer.data);
});
// you can have other layer types
map.layers.forEach(layer => {
if(layer.type === 'tilelayer') {
pako.inflate(layer.data);
}
});
from tiled-types.
This is strange. My map only has tilelayer type objects in layers, but tiled-types detects imagelayer...
{
"compressionlevel": -1,
"height": 50,
"infinite": false,
"layers": [
{
"compression": "zlib",
"data": "eJztlFsOgjAQRQl8CN2IwEbFxz7Exz7Ex6K8PyaTQUNbDTM183GSmSbT0HtKyyLLKuBAmXBdgwa0idfSOc7tg85qcfCND6fIQaiPT3tIO/D1QXstuYf64Odwb9xIO/DxURfj/9v3vmny8arpWUoFucf44LnTNQ0OYt4r7kKDA9/3it4tOqvFQagPfg4tDnx98LfrH3zQ/0KLg1AfKdTSOZoP8zFHvcjRgwq4fNyn4mOJb61BA9p83JsP82HvVfrvlfnQk6n5kM/RfJgPzbV0jubDfGiupXM0H+ZDcy2do/kwH5pr6Rx/Va/AGmzANoKOzXcEvh7bT+23A3twAEdwiqBn8z2Br8f2U/udwQVcwQ3cIxjY/EDg67H91H4P8AS1PGLR",
"encoding": "base64",
"height": 50,
"id": 1,
"name": "Ground",
"opacity": 1,
"type": "tilelayer",
"visible": true,
"width": 50,
"x": 0,
"y": 0
},
...
],
...
}
from tiled-types.
That was fast! Thank you very much @Chnapy !
from tiled-types.
Related Issues (7)
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 tiled-types.