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

Expose map.getImage #5735

Closed
alex3165 opened this issue Nov 21, 2017 · 3 comments
Closed

Expose map.getImage #5735

alex3165 opened this issue Nov 21, 2017 · 3 comments
Labels
feature 🍏 GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform

Comments

@alex3165
Copy link
Contributor

Hello,

I would need to know if an image has already been added or not, would it be possible to expose a map.getImage function? I can see that addImage is already "protected":

  if (this.imageManager.getImage(id)) {
    return this.fire('error', {error: new Error('An image with this name already exists.')});
  }

But I would like to avoid the error message and prevent from calling map.addImage upfront by checking is the image is already there in my application.

mapbox-gl-js version: 0.42.2

@1ec5 1ec5 added the GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform label Nov 22, 2017
@ArturAntonov
Copy link

I found some error. And 'try-catch' not helping.

try {
          this.map.addImage('arrow-head', image);
        } catch (e) {
          console.log('image with id "arrow-head" is already exists');
        }

Even if i use 'try-catch' i still get error.

vendor.bundle.js:44292 Error: An image with this name already exists.
    at t.addImage (vendor.bundle.js:44178) [angular]
    at e.addImage (vendor.bundle.js:44266) [angular]

Is the method "addImage" async?

@mollymerp
Copy link
Contributor

@alex3165 we would gladly accept a PR implementing this method!

@1ec5
Copy link
Contributor

1ec5 commented Nov 8, 2018

Note that #5775 implemented a Boolean hasImage() method but not a getImage() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🍏 GL native → GL JS For feature parity with Mapbox Maps SDK on a native platform
Projects
None yet
Development

No branches or pull requests

5 participants