Last active
February 13, 2018 17:48
-
-
Save escapedcat/1a85dc3f04d9689ce48e to your computer and use it in GitHub Desktop.
angular-google-maps directions service example
This file contains 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
addresses = addressService.query(); | |
addresses.$promise.then(function (result) { | |
console.log('task query done'); | |
createWaypointsFromAddresses(addresses); | |
return uiGmapGoogleMapApi; | |
}) | |
.then( function(maps) { | |
console.log('uiGmapGoogleMapApi done'); | |
$scope.map = { | |
center: { latitude: 0, longitude: 0 }, | |
zoom: 16 | |
}; | |
$scope.directionsService = new maps.DirectionsService(); | |
$scope.directionsDisplay = new maps.DirectionsRenderer(); | |
return uiGmapIsReady.promise(1); | |
}) | |
.then( function(instances) { | |
console.log('uiGmapIsReady done'); | |
var instanceMap = instances[0].map; | |
$scope.directionsDisplay.setMap(instanceMap); | |
$scope.directionsService.route(directionsServiceRequest, function(response, status) { | |
if (status == google.maps.DirectionsStatus.OK) { | |
$scope.directionsDisplay.setDirections(response); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment