diff --git a/README.md b/README.md index 869dfaf..c6fedd3 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,10 @@ Sets the center of the map. `animated` property defaults to `true`. Shows the user's location on the map. Must be called in the view initialization sequence on `will_appear` or _after_. +#### track_user_location({ heading: true }) + +Causes the map view to center the map on that location and begin tracking the user’s location. `heading` defaults to false but will provide a compass heading if set to true. + #### look_up_location(CLLocation) { |placemark, error| } This method takes a CLLocation object and will return one to many CLPlacemark to represent nearby data. diff --git a/lib/ProMotion/map/map_screen_module.rb b/lib/ProMotion/map/map_screen_module.rb index c4f5c6c..0dda687 100644 --- a/lib/ProMotion/map/map_screen_module.rb +++ b/lib/ProMotion/map/map_screen_module.rb @@ -73,6 +73,15 @@ def showing_user_location? self.view.showsUserLocation end + def track_user_location params={} + params = {heading: false}.merge(params) + set_track_user_location params[:heading] + end + + def set_track_user_location heading + self.view.userTrackingMode = heading ? MKUserTrackingModeFollowWithHeading : MKUserTrackingModeFollow + end + def user_location user_annotation.nil? ? nil : user_annotation.coordinate end