Skip to content

Instantly share code, notes, and snippets.

@escapedcat
Last active February 13, 2018 17:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save escapedcat/1a85dc3f04d9689ce48e to your computer and use it in GitHub Desktop.
Save escapedcat/1a85dc3f04d9689ce48e to your computer and use it in GitHub Desktop.
angular-google-maps directions service example
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