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

[Documentation] How to add access token. #27

Open
j-mcnally opened this issue Jun 27, 2015 · 6 comments
Open

[Documentation] How to add access token. #27

j-mcnally opened this issue Jun 27, 2015 · 6 comments

Comments

@j-mcnally
Copy link

I've added

mapboxService.init({ accessToken: 'YOUR_ACCESS_TOKEN' });

a few times, but its not being used when requesting tiles.

I've tried it in my run and config. Where do I put it?

@j-mcnally j-mcnally changed the title How to add access token. [Documentation] How to add access token. Jun 27, 2015
@j-mcnally
Copy link
Author

So my issue is in the documentation it lists an old js / css version.

@abhishekU
Copy link

Inside controller would work

@joelkinzel
Copy link

For those reading this, you need to inject the mapboxService like so:

angular.module('starter', ['angular-mapbox']).run(function(mapboxService){
   mapboxService.init({ accessToken: 'YOUR_API_KEY' });
})

@tinker20
Copy link

Hi @joelkinzel . I tried adding this code to my index.html file:-

<script> var app = angular.module('Kawasaki', ['ui.router', 'ngStamplay', 'angular-mapbox']).run(function(mapboxService){ mapboxService.init({ accessToken: 'MY_API_KEY' }); }) </script>

The screenshot contains the header response of the network calls which shows that the map isn't displayed because of a 401(Unauthorized) error.

How ti fix this?
screenshot from 2015-09-11 14 33 07

@joelkinzel
Copy link

@tinker20 - This should go inside your Angular controller file.

@tinker20
Copy link

Hi Joel,

I have tried adding this to the controller. Still the request is
unauthorized.

angular.module('starter', ['angular-mapbox']).run(function(mapboxService){
mapboxService.init({ accessToken:
'ACCESS_TOKEN' });
})
app.controller('MenuCtrl', ['$scope', '$http','$stamplay'
,'userStatus','storefront', 'globalVariable', 'qId',
function MenuCtrl($scope, $http, $stamplay, userStatus, storefront,
globalVariable, paramValue) {

    //Call service
    //if user was defined -> update $scope
    var user = userStatus.getUserModel()
    user.currentUser().then(function(){
        if(user.isLogged()){
                $scope.user = {};
                $scope.user.logged = true;
                $scope.user.displayName = user.instance.displayName;
                $scope.user.picture = user.instance.profileImg;
                $scope.user._id = user.instance._id;
                userStatus.setUser(user.instance.displayName,

user.instance.profileImg, user.instance._id, user.instance.email, true)
getStorefront(paramValue, false)
}else{
getStorefront(paramValue, true)
}
}, function(){
getStorefront(paramValue, true)
})

Any help with that?

Thanks

On Fri, Sep 11, 2015 at 5:20 PM, joelkinzel [email protected]
wrote:

@tinker20 https://github.com/tinker20 - This should go inside your
Angular controller file.


Reply to this email directly or view it on GitHub
#27 (comment)
.

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

4 participants