Search code examples
google-mapsng-map

ng-map: how to set origin to current location for directions?


I'm using AngularJS and ng-map.

How can I set the directions origin to my current location?

I've tried:

<directions 
    destination="..."
    origin="current-location">
</directions>
  

But this causes the map to not render anything.

Thank you for the help to set my current location as the origin.

Karl


Solution

  • It's currently not supported but is on the backlog.

    Allen provided the following response to acquire the current location using an API call:

    https://github.com/allenhwkim/angularjs-google-maps/blob/master/services/navigator_geolocation.js

    NavigatorGeolocation.getCurrentPosition().then(function(pos) { ... });