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

Add Map#loadImage method and Map#addImage examples #4478

Merged
merged 3 commits into from
Mar 27, 2017
Merged

Conversation

lucaswoj
Copy link
Contributor

This PR:

  • exposes ajax#getImage as Map#loadImage for use with Map#addImage
  • adds an example using Map#addImage with an external URL
  • adds an example using Map#addImage with a procedurally generated image

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality 😬
  • document any changes to public APIs
  • manually test the debug page

@lucaswoj lucaswoj changed the title Add Map#loadImage method and "Map#addImage" examples Add Map#loadImage method and Map#addImage examples Mar 22, 2017
@@ -5,7 +5,8 @@
"MapboxGeocoder": true,
"MapboxDirections": true,
"turf": true,
"d3": true
"d3": true,
"Uint8Array": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember why we have es6 env set to false a few lines below? As far as I remember, turning this back to true would allow not specifying common globals like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As best I remember we were just to avoid using es6 features with limited browser support. This is less of a concern now. I have enabled the "es6" flag and removed this global in the latest commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to continue to write examples without using ES6 features such as let/const or arrow functions (not supported by iOS 9) and for...of (not supported by IE 11). I think it's useful to keep this configuration option to catch accidental uses of these types of features. I suggest we revert the latest commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right -- the examples don't get bubleifyied. I'll revert the last commit and leave a comment about this in the eslint file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfirebaugh as far as I remember, the env switches are only for predefined globals like Uint8Array — they're not used for catching keywords like let.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. And "parserOptions": { "ecmaVersion": 5 } doesn't work either. 😞

Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting these together @lucaswoj!
These look great, but I wonder if we could make our terminology more consistent/clear? Should the methods themselves be called "addSprite" (I realize it's a little late to be making this suggestion 😬)? and should these examples refer to sprites instead of icons?

icon- specifically refers to symbol layers in the style-spec, but these icons can also be used by -pattern layers as well, right?

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 22, 2017

@mollymerp There's a bunch of context on the naming decisions here: mapbox/mapbox-gl-style-spec#220 (comment) and #2059 (comment)

There's a case to be made that these examples should be titled "Add an image to the map" but I think the current names will best direct those looking for this functionality.

Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐑

@lucaswoj lucaswoj merged commit f458b59 into master Mar 27, 2017
@lucaswoj lucaswoj deleted the addimage-example branch March 27, 2017 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants