App-map directive in tabs project works once for gotoLocation()

I am trying to get the code in http://jsfiddle.net/Wijmo/Rqcsj/ to work on a tabs project.

I created a fresh tabs project “ionic start app-map-tabs tabs” and then I added the code from the above
example into the Account tabs.

I can see the map and the markers fine, but the gotoLocation function only works the first time, after that
it doesn’t.

$scope.gotoLocation = function (lat, lon) {
    if ($scope.lat != lat || $scope.lon != lon) {
        $scope.loc = { lat: lat, lon: lon };
        if (!$scope.$$phase) $scope.$apply("loc");
    }
};

I think there is some issue with scoping here…

Could someone please help?

I have placed all the code I created in https://github.com/csarnevesht/ionic-map-tabs

Any help would be greatly appreciated!

Try wrapping it inside of a view event.

$scope.$on('$ionicView.enter'. function(){
// Geolocation code here
});