Ng-map: cannot get map object to controller

As shown in this example using the api ngmap direction, the 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 this variable inside my controller because I want to create my own direction panel

I tried using $scope.mapin the controller, but it does not work.

Please, help.

+4
source share
1 answer

In your controller, you want to initialize the map object as follows:

		$scope.$on('mapInitialized', function(event, map) {
			map.setOptions({
			});
		});
Run codeHide result

, , init, side map.setOptions.

$scope.map

+4

Source: https://habr.com/ru/post/1614683/


All Articles