[TIMOB-9187] Ti.map.view add direct access to user's currentlocation
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Low |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | api |
| Reporter | Vincent |
| Assignee | Unknown |
| Created | 2012-05-15T04:54:08.000+0000 |
| Updated | 2018-02-28T20:04:10.000+0000 |
Description
give access to MKUserLocation location @property(readonly, retain, nonatomic) CLLocation *location
from the mapview ( no need to listen for GPS event in a mapview)
constraint :
@property(readonly, nonatomic, getter=isUpdating) BOOL updating should also be exposed
could be also implemented under a new event for the mapview returning a LocationCoordinates object each time the userLocation is updated
that's what I did
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { if ([self.proxy _hasListeners:@"userLocation"]) { CLLocation* myLocation = [userLocation location]; CLLocationCoordinate2D coord = [myLocation coordinate]; NSDictionary * props = @{ @"latitude": @(coord.latitude), @"longitude": @(coord.longitude), @"heading": @(myLocation.course ), @"timestamp": @([ myLocation.timestamp timeIntervalSince1970] * 1000 ), }; [self.proxy fireEvent:@"userLocation" withObject:props]; } }