Placing blue point in mapKit with desired location

For demo purpose, I need to simulate the user's location in a Mapkit view. It looks like with the undocumented API it is possible to place the blue dot anywhere on the map. Sorry I don't know what to use the documentless API? Any help?

+2


a source to share


2 answers


Have you installed this?

mapView.showsUserLocation = YES;

      



Setting up a specific location is a bit tricky, but can certainly work without the undocumented APIs. See the following code:

- (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;
}

      

0


a source


Not sure if it is possible to set a custom CUSTOM location (usually people use the user's blue dot image). Although I'm not 100% sure, so you have a chance to try something like this to see if it's possible to deal with userLocation like MKAnnotation ...



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

      

0


a source







All Articles