1
votes

I'm having problems taking the first few steps with MapBox iOS SDK (1.4.1).

I've started with the suggested code over here: https://www.mapbox.com/mapbox-ios-sdk/examples/

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.mapBoxView.tileSource = [[RMMapboxSource alloc] initWithMapID:@"my_map_id" enablingDataOnMapView:_mapBoxView];
    self.mapBoxView.userTrackingMode = RMUserTrackingModeNone;

    CLLocationCoordinate2D centerLocation;
    centerLocation.latitude = NRMapStartLatitude;
    centerLocation.longitude = NRMapStartLongitude;
    
    [self.mapBoxView setCenterCoordinate:centerLocation];
    [self.mapBoxView setZoom:7 animated:YES];
}

No matter what I do the map starts at a location in Washington D.C. but I've set the center coordinate to be somewhere in Europe.

The same with the zoom. No matter what value I try it has no effect on the map.

There's something with the NSLog output that confuses me. At startup it says:

Using watermarked example map ID examples.map-z2effxa8. Please go to https://mapbox.com and create your own map style.

I was assuming that this is something that I already did by registering for a free account there and starting with my first project.

Added the tilesource 'My First Map' to the container

Origin is calculated at: 120.786199, -85.000000 Map initialised. tileSource:RMMapboxSource: Mapbox iOS Example, zooms 0-19, no interactivity, minZoom:2.000000, maxZoom:18.000000, zoom:18.000000 at {-77.032458,38.913175}

Apparently the sample project in the iOS SDK is loaded and ignoring everything else I try to configure.

So, how do I configure the map so I can interact with the API. What am I missing?

Any kind of help is highly appreciated. Thank you!

1
Apparently setting the zoom in viewDidAppear does cause the map to apply the desired zoom level. However I'm still trying to find out why I can't set the center coordinate. It's always set to Washington D.C. - MrBr

1 Answers

1
votes

OK, whoever is struggling with that. The trick is to set the zoom BEFORE you set the center coordinate..

..for whatever reason.