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

Access Token #5

Closed
scottzirkel opened this issue Aug 8, 2014 · 5 comments
Closed

Access Token #5

scottzirkel opened this issue Aug 8, 2014 · 5 comments

Comments

@scottzirkel
Copy link

When I use angular-mapbox.js I get errors saying I need to include the access token, yet when I use angular-mapbox-standalone.js I do not and the map appears (though I'm loading angular more than once). Do I need to include the access token someplace when using angular-mapbox.js?

@sllvn
Copy link
Owner

sllvn commented Aug 9, 2014

I'm not sure about an access token error; the only required key should be your mapbox ID (as an attribute (map-id) on the <mapbox> element) and the effect of leaving that out would be that the map tiles don't load (markers will still display, but just over an empty canvas instead of map tiles).

I am going to move away from angular-mapbox-standalone, as that was more an idea of letting complete non-techies use the library. I've changed my thinking on that; I now believe a library of that nature should be written as a web component with Polymer.js, rather than an Angular library.

If you feel like gisting your source code, I'd be happy to take a look.

@scottzirkel
Copy link
Author

Here's what I have:

<mapbox map-id="MY-MAP-ID" width="80%">
<div ng-repeat="map in mapData | filter:currentMap">
  <marker lat="{{ pin.lat }}" lng="{{ pin.lon }}" color="{{ map.color }}" symbol="{{ map.symbol }}" ng-repeat="pin in map.pins">
    <h2>{{ pin.name }}</h2>
    <address>{{pin.address}}</address>
  </marker>
</div>
</mapbox>

And here are the two errors I get:

angularMapbox was already loaded angular-mapbox.js:8
Error: An API access token is required to use Mapbox.js. See https://www.mapbox.com/mapbox.js/api/v2.0.0/l-mapbox-accessToken/

@scottzirkel
Copy link
Author

OK, so if I add
<script charset="utf-8"> L.mapbox.accessToken = 'PUBLIC-KEY'; </script>
before calling in the angular-mapbox.js file, it works. Not sure why others don't seem to need it, that's just what Mapbox tells me to use.

The first error about it already being loaded persists however.

@gmschmitz
Copy link

thanks Scott, that worked for me as well

@sllvn
Copy link
Owner

sllvn commented Dec 28, 2014

Hi, this was a compatability issue with Mapbox.js 2.0 (which now requires the API access token). I've updated the set of directives to work with 2.0, but the access token is still required. You can either set it by directly accessing the Mapbox.js library or by injecting mapboxService and calling mapboxService.init({ accessToken: 'YOUR_ACCESS_TOKEN' });

This is addressed in v0.1.3 (363b01b) and docs have been updated.

@sllvn sllvn closed this as completed Dec 28, 2014
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

No branches or pull requests

3 participants