sllvn / angular-mapbox

DEPRECATED - use tombatossals/angular-leaflet-directive instead
73 stars 29 forks source link

[Documentation] How to add access token. #27

Open j-mcnally opened 9 years ago

j-mcnally commented 9 years ago

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 commented 9 years ago

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

abhishekU commented 9 years ago

Inside controller would work

joelkinzel commented 9 years ago

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 commented 9 years ago

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

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 commented 9 years ago

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

tinker20 commented 9 years ago

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 notifications@github.com wrote:

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

— Reply to this email directly or view it on GitHub https://github.com/licyeus/angular-mapbox/issues/27#issuecomment-139526430 .