As shown in this example of using direction api of ngmap, a map variable is used to get the total length of the route.
{{map.directionsRenderers[0].directions.routes[0].overview_path.length}}
as in the example below.
view-source:https://rawgit.com/allenhwkim/angularjs-google-maps/master/testapp/directions.html
But i want that variable inside my controller because I want to make my own direction-panel
I tried using $scope.map
in the controller, but it doesn't work.
Please help.
In your controller, you want to initilize the map object like so:
$scope.$on('mapInitialized', function(event, map) {
map.setOptions({
});
});
Obviously, any options you want to set on init would be declared in side map.setOptions.
Once that is initialized, you should be able to reference it using $scope.map