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 description on how to set API key per style #2

Closed
nvkelso opened this issue Nov 9, 2016 · 11 comments · Fixed by #6
Closed

Add description on how to set API key per style #2

nvkelso opened this issue Nov 9, 2016 · 11 comments · Fixed by #6
Assignees

Comments

@nvkelso
Copy link
Member

nvkelso commented Nov 9, 2016

Most the styles must be updated to allow this, though.

Question: /cc @bcamper

  • Should Mapzen house styles styles continue to ship with Mapzen's API keys set or leave that blank?

If we remove it, then our product pages would need to set them on map init, and the Github repo index pages would also need to set them on init.

@nvkelso
Copy link
Member Author

nvkelso commented Nov 9, 2016

Confirmed this approach with Brett:

Using Tangram's JS API:

    var layer = Tangram.leafletLayer({
        scene: { import: style_file, global: { sdk_mapzen_api_key: 'mapzen-xxxxxx' } },
        attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a> | &copy; OSM contributors | <a href="https://mapzen.com/" target="_blank">Mapzen</a>'
    });

The house style YAML files would change something like:

global:
    # Sign up for a Mapzen API key to enjoy higher rate limits
    # https://mapzen.com/documentation/overview/#developer-accounts-and-api-keys
    sdk_mapzen_api_key: ''     # set this value to your Mapzen API key

sources:
    mapzen:
        type: MVT
        url:  https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.mvt
        max_zoom: 16
        url_params:
            api_key: global.sdk_mapzen_api_key
    normals:
        type: Raster
        url: https://tile.mapzen.com/mapzen/terrain/v1/normal/{z}/{x}/{y}.png
        max_zoom: 15
        url_params:
            api_key: global.sdk_mapzen_api_key

(updated 2016.12.22 and again 2017.01.05)

@nvkelso
Copy link
Member Author

nvkelso commented Nov 9, 2016

/cc @kkowalsky

@kkowalsky
Copy link
Collaborator

hey @meetar do you mind double checking this?

@kkowalsky kkowalsky self-assigned this Nov 9, 2016
@nvkelso
Copy link
Member Author

nvkelso commented Nov 9, 2016

The new sdk_mapzen_api_key global would be added to the API reference page, then the Tangram JS API stuff would go into get-started/#tangram. I believe Tangram ES is currently adding support for the same.

(updated)

@meetar
Copy link
Member

meetar commented Nov 17, 2016

@kkowalsky The example looks good, though I don't know anything about the sdk_mapzen_api_key parameter.

(updated)

@nvkelso
Copy link
Member Author

nvkelso commented Nov 17, 2016

@meetar the new sdk_mapzen_api_key will be added to house styles as a Tangram global property that'll I'll plumb thru as a URL param for sources.

(updated)

@nvkelso
Copy link
Member Author

nvkelso commented Nov 28, 2016

@blair1618 Does Tangram ES support url_params in sources yet? Can you link the related issue here, please?

@tallytalwar
Copy link
Member

ES does support url_params in sources.

@nvkelso
Copy link
Member Author

nvkelso commented Nov 28, 2016

@tallytalwar Nice! What's the ES equivalent code snippet to JS's:

Scene.load({
      import: 'https://mapzen.com/carto/bubble-wrap-style/bubble-wrap.yaml',
      global: { sdk_mapzen_api_key: `XXX` }
    });

@matteblair
Copy link
Member

matteblair commented Dec 14, 2016

In our C++ interface you could do this:

map->loadScene(
    "https://mapzen.com/carto/bubble-wrap-style/bubble-wrap.yaml",
    false,
    { "global.sdk_mapzen_api_key", "mapzen-xxxxxx" }
);

We're currently working on the Android interface for this (tangrams/tangram-es#1173).

(updated 2016.12.22 for global variable name and 2017.01.05 for example key)

@nvkelso
Copy link
Member Author

nvkelso commented Dec 14, 2016

(Bubble Wrap and Refill already support the general url_params syntax, but need to move towards generic SDK approach still.)

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 a pull request may close this issue.

5 participants