开发者

GPS location on map in application

I have one application that shows maps. I need to show 开发者_C百科current position of user and manage to do that with

[mapView setShowsLocation:YES];

But when I zoom In or zoom Out map it needs a lot of time to show me that blue pin again.

Is it normal or I need to put something else to keep that blue pin on screen all time???

Thanks.


[self setCurrentLocation:self._mapView.userLocation.location.coordinate withZoom:1.0];
self._mapView.showsUserLocation = YES;

- (void)setCurrentLocation:(CLLocationCoordinate2D)coord withZoom:(float)zoomLevel {
    MKCoordinateRegion region = self._mapView.region;
    region.span.latitudeDelta = self.defaultSpanLevel.latitudeDelta*zoomLevel;
    region.span.longitudeDelta = self.defaultSpanLevel.longitudeDelta*zoomLevel;
    region.center = coord;
    [self._mapView setRegion:region animated:YES];
}

You can use this in view will appear Method

Then You can use mapview delegate methods....

region did change animated:YES { and set map's region here.... take current user location as region centre.. }

This will solve your problem

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜