Created
October 13, 2015 21:31
-
-
Save thesabbir/e199028ed01ba52c0265 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| angular.module('position') | |
| .controller('PositionCtrl', function ($scope, uiGmapGoogleMapApi, uiGmapIsReady,$state, $stateParams) { | |
| if($stateParams.request == null) { | |
| $state.go('app.request'); | |
| } | |
| console.log('PositionCtrl'); | |
| document.querySelector('.angular-google-map-container').style.height = document.body.clientHeight + 'px'; | |
| uiGmapGoogleMapApi.then(function (maps) { | |
| //Map | |
| $scope.map = { | |
| center: { | |
| latitude:0 , | |
| longitude:0 | |
| }, | |
| zoom: 16, | |
| options: { | |
| panControl: false, | |
| scaleControl: false, | |
| streetViewControl: false, | |
| zoomControl: false | |
| } | |
| }; | |
| $scope.directionsService = new maps.DirectionsService(); | |
| $scope.directionsDisplay = new maps.DirectionsRenderer(); | |
| return uiGmapIsReady.promise(1); | |
| }).then(function (instances) { | |
| console.log($stateParams); | |
| var instanceMap = instances[0].map; | |
| var origin = $stateParams.request.pickup_address; | |
| var destination = $stateParams.request.destination_address; | |
| $scope.directionsDisplay.setMap(instanceMap); | |
| $scope.directionsService.route({ | |
| origin: origin, | |
| destination: destination, | |
| travelMode: "DRIVING", | |
| durationInTraffic: true | |
| }, function (response, status) { | |
| console.log(response); | |
| console.log(status); | |
| $scope.directionsDisplay.setDirections(response); | |
| }); | |
| google.maps.event.trigger($scope.map, 'resize'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment