开发者

Placing blue dot in mapKit with a desired location

开发者 https://www.devze.com 2022-12-29 17:20 出处:网络
For demonstration purpose, i need to simulate the user location in a Mapkit view. It seems that it is possible with an undocumented API toplace the blue dot anywhere on the map view.

For demonstration purpose, i need to simulate the user location in a Mapkit view. It seems that it is possible with an undocumented API to place the blue dot anywhere on the map view. Unfortunately, i don't know witc开发者_JAVA百科h undocumented API to use ? Any help ?


Did you set this?

mapView.showsUserLocation = YES;

Setting a specific location is a bit more difficult, but certainly do-able without undocumented APIs. See code below:

- (void)animateToSelectedPlace:(CGFloat)zoomLevel {
    MKCoordinateRegion region;
    region.center = [self getCoordinateFromComponents:chosenLatitude:chosenLongitude];

    MKCoordinateSpan span = {zoomLevel,zoomLevel};
    region.span = span;

    [mapView setRegion:region animated:YES];
}

-(CLLocationCoordinate2D)getCoordinateFromComponents:(NSNumber*)latitude:(NSNumber*)longitude {
    CLLocationCoordinate2D coord;
    coord.latitude = latitude.doubleValue;
    coord.longitude = longitude.doubleValue;
    return coord;
}


Not sure that it is possible to set CUSTOM user location (usually people use image simulating blue user point). Though i am not 100% sure, so you have a chance to try something like this to check if it is possible to deal with userLocation as with MKAnnotation ...

CLLocationCoordinate2D c = self.mapView.userLocation.location.coordinate;
[[self.mapView userLocation] setCoordinate:c];
0

精彩评论

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

关注公众号