Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having trouble with IconLayer pre-packed iconAtlas #4598

Closed
cooperrf opened this issue May 17, 2020 · 6 comments
Closed

Having trouble with IconLayer pre-packed iconAtlas #4598

cooperrf opened this issue May 17, 2020 · 6 comments
Labels

Comments

@cooperrf
Copy link

Hello,

I'm receiving this error when trying to create an icon layer with a pre-packed icon atlas:
Error: No valid loader found for data starting with "" for ./assets/map/marker-icon.png

I confirmed the png and json are loading. I'm seeing 200s for them in the network tab of the developer console.

My code looks like this:

const layer:IconLayer<any> = new IconLayer<any>({
    data: this._data,
    iconAtlas: './assets/map/marker-icon.png',
    iconMapping: './assets/map/marker-icon-mapping.json',
    getIcon: d => 'marker',
    getSize: 50,
    getPosition: d => d.geometry.coordinates
});
this._deck.setProps({
    layers: [layer]
});

I also tried an object for the icon mapping instead of a URL:

    ...
    iconAtlas: './assets/map/marker-icon.png',
    //iconMapping: './assets/map/marker-icon-mapping.json',
    iconMapping: {
      marker: {
        x: 0,
        y: 0,
        width: 320,
        height: 511,
        mask: false
      }
    },
    ...

Still no luck.

Note that this layer is part of a suite of angular components I've built. Other layer types are working just fine (geojson, trips, arc, and hexagons).

Auto-packing does work as expected:

    ...
    //iconAtlas: './assets/map/marker-icon.png',
    //iconMapping: './assets/map/marker-icon-mapping.json',
    getIcon: (d) => {
        return {
            url: './assets/map/marker-icon.png',
            x: 0,
            y: 0,
            width: 320,
            height: 511,
            mask: false
        };
    },
    ...

I've got this stuff in package.json:

    ...
    "@deck.gl/aggregation-layers": "^8.1.6",
    "@deck.gl/core": "^8.1.6",
    "@deck.gl/geo-layers": "^8.1.6",
    "@deck.gl/layers": "^8.1.6",
    "@deck.gl/mesh-layers": "^8.1.6",
    "@luma.gl/core": "^8.1.2",
    ...

Here's the icon atlas and icon mapping files I'm trying to load:
assets.zip

Please help!

@cooperrf cooperrf added the bug label May 17, 2020
@Pessimistress
Copy link
Collaborator

Run yarn list @loaders.gl/core at your project root and confirm that you have only one copy.

@cooperrf
Copy link
Author

cooperrf commented May 18, 2020

Hello. Thanks for the quick response!

The project I'm working on uses npm. But I did try npm list@loaders.gl/core with the attached result (some deduping). I tried installing individual loader.gl modules (core and images). I deleted the node_modules directory and did a fresh install. The browser thinks the image loaded, but I'm still seeing the same error.

I'm looked through the source code a little, but didn't get far. Is there some avenue I can explore for debugging? Is it strange that auto-packing works but pre-packing does not?

Thanks!

npm list@loaders.gl/core:
Screen Shot 2020-05-17 at 10 02 20 PM

Image seems to load:
Screen Shot 2020-05-17 at 10 14 03 PM

Console error:
Screen Shot 2020-05-17 at 10 07 37 PM

@Pessimistress
Copy link
Collaborator

Pessimistress commented May 18, 2020

I remember some old issues when building with Angular due to certain aggressive optimization. If it's possible to examine the compiled code, you can check if this line is called at all:

registerLoaders([jsonLoader, ImageLoader]);

@cooperrf
Copy link
Author

cooperrf commented May 18, 2020

Success!

I didn't find registerLoaders([jsonLoader, ImageLoader]); in my compiled code.

I don't know if this was the best way to do it (maybe you can confirm), but I'm manually registering the loaders in my application code:

import {registerLoaders} from '@loaders.gl/core';
import jsonLoader from '@deck.gl/core/dist/esm/utils/json-loader';
import {ImageLoader} from '@loaders.gl/images';

...

registerLoaders([jsonLoader, ImageLoader]);

Thanks for the quick help!

If this is my best option, we can close this ticket. :)

@Pessimistress
Copy link
Collaborator

Let's keep the ticket open for now. We should still figure out how to fix it properly with Angular, maybe there is a build config?

@Pessimistress
Copy link
Collaborator

@cooperrf Can you point me to a minimal setup that reproduces this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants