MapBox loads wrong map - ios

I followed the installation steps from mapbox ios sdk. Then, i run my app in simulator and everything was right with the example map id into RMMapBoxSource.Although when i made a custom map in mapbox online and tried to load it into my app it always loads a map from Washighton DC city and not my custom map. Can anyone tell me whats going wrong with this? Here is the code from the controller that tries to load map:
- (void)viewDidLoad
{
[super viewDidLoad];
RMMapBoxSource *tileSource = [[RMMapBoxSource alloc] initWithMapID:#"hoya21.map-nkbz19y4"];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
[self.view addSubview:mapView];
}

Go to mapbox.com, open up your map project, click the gear at the top of the window next to the map name and then check the box next to "Save current map position".

Related

How to set MKMapView maptype without using attribute?

Currently learning iOS development. I need to set my instance of MKMapView to display with satellite view. I know I can do this through the attribute settings, but I wish to do it through code using [myMapView setMapType:MKMapTypeSatellite], but my question is, where do I put this so that as soon as the mapView loads on the screen, it is already in satellite mode. My instinct is to send this message once my instance of mapview is instantiated, but where does this occur?
Typically this type of code is put into the view controller's viewDidLoad method, which is called once for each instance of a controller.
- (void)viewDidLoad {
[super viewDidLoad];
myMapView = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,200,200)];
myMapView.mapType = MKMapTypeSatellite;
[self.view addSubview:myMapView];
}

Mapbox online map on iOS

I'm totally new to mapbox API on iOS , i follow the instruction on there site and make a custom map with marker -
My Map Online Link
- and i add the binary framework and it load with the map without any marker
#import <MapBox/MapBox.h>
-(void)viewWillAppear:(BOOL)animated{
RMMapView *map =[[RMMapBoxSource alloc]initWithMapID:#"scorpioo.map-a6l64b06"];
RMMapView *mapV = [[RMMapView alloc] initWithFrame:view.bounds andTilesource:map];
}
so anyone can tell me why it not shown ? or know how can i show the marker that i put on the online map on my ios ?
This is possible using this method of RMMapBoxSource:
http://www.mapbox.com/mapbox-ios-sdk/api/#//api/name/initWithMapID:enablingDataOnMapView:
Create your RMMapView first, then create your RMMapBoxSource, pass the map view as the second argument. This will pull down server-side markers and automatically display them.
Here is an example project which shows this:
https://github.com/mapbox/weekend-picks-template-ios
The technology here is called simplestyle.
You need to add the following lines in the above code. So that you can get the desired marker :
RMPointAnnotation *annotation = [[RMPointAnnotation alloc] initWithMapView:map coordinate:MENTION_COORDINATES_HERE andTitle:#"Hello, world!"];
[mapView addAnnotation:annotation];
Complete Example :
RMMapBoxSource *tileSource = [[RMMapBoxSource alloc] initWithMapID:#"examples.map-z2effxa8"];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
[self.view addSubview:mapView];
RMPointAnnotation *annotation = [[RMPointAnnotation alloc] initWithMapView:mapView
coordinate:mapView.centerCoordinate
andTitle:#"Hello, world!"];
[mapView addAnnotation:annotation];
Hope that helps.

Camera controls in Zbar

Hi I am trying to show camera controls using zbar in ios for scanning.
i have written following code
ZBarReaderViewController *readerController = [[ZBarReaderViewController alloc] init];
readerController.sourceType = UIImagePickerControllerSourceTypeCamera;
readerController.tracksSymbols = YES;
readerController.showsCameraControls = YES;
readerController.showsZBarControls = YES;
[readerController release];
But application crash every time when i show zbar controller.
and app work fine if i remove this line
readerController.showsCameraControls = YES;
But then i can not see any control on scan view
"BOOL showsCameraControls Raises an exception if anything other than NO is set."
Check the following link for details: ZBarReaderViewController Class Reference. Cheers

Same functionality of MKUserTrackingBarButtonItem but "manually/programmatically" on iOS

I want to have the same functionality of MKUserTrackingBarButtonItem on a Map but I want to do it programmatically.
Normally using I do this on ViewController
- (void) viewDidLoad
{
...
MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.map];
self.navigationItem.rightBarButtonItem = buttonItem;
...
}
But I want to try it by code. I know how to get the UserLocation, but how can I get the compass functionality?
I know it's an old post but isn't compass functionality the "heading"? And so, you can set the tracking mode of the map by changing the userTrackingMode of the MKMapView.

Google Maps directions in maps shared app to personalized annotations

I created an app that displays different points on a custom map with custom pins and showing the title and subtitle with a disclosure button (all right). The problem arises when the app launches maps to create the path and then provide directions. To move from the position of the user I've simply typed in the URL "saddr=Current Position". The problem comes when I try to give the destination that the user has touched, relative to the pin touched.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
[self.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];
NSString* addr = [NSString stringWithFormat:#"http://maps.google.com/maps?daddr=%1.6f%1.6f&saddr=Posizione Attuale", mapView.annotations.coordinate.latitude mapView.annotations.coordinate.longitude];
//also mapview.annotation.coordinate.latitude/longitude doesn't work
NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
I can not figure out how to pass the coordinates of the annotation in the piece of code!
Here's how I said and added the annotation to my view
NSMutableArray* annotations=[[NSMutableArray alloc] init];
CLLocationCoordinate2D theCoordinate1;
theCoordinate1.latitude = 45.7;
theCoordinate1.longitude = 7.64;
myAnnotation* myAnnotation1=[[myAnnotation alloc] init];
myAnnotation1.coordinate=theCoordinate1;
myAnnotation1.title=#"Pippo";
myAnnotation1.subtitle=#"Ufficio";
[myMapView addAnnotation:myAnnotation1];
This repeated for 4 main points that have different names (myAnnotation1, 2, 3, 4) and coordinates other! How can I do when the user touches 1-2-3 or 4 to move the right destination?
Thanks in advance! :)
In calloutAccessoryControlTapped, why are you pushing a blank view controller and calling openURL at the same time?
Anyway, the annotation's coordinates are in view.annotation.coordinate.
So the latitude is view.annotation.coordinate.latitude and longitude is view.annotation.coordinate.longitude.
Also, in your addr string, you are missing a comma between the coordinates.

Resources