how to show custom map in MapBox IOS sdk - ios

I am new in MapBox IOS sdk and i have no idea,how to load custom Map in MapBox.
Here my Custom Map:
https://api.tiles.mapbox.com/v4/faridullah.loj1n5f3/page.html?access_token=pk.eyJ1IjoiZmFyaWR1bGxhaCIsImEiOiJVU3ZCNS1VIn0.Owqu7VB5OZQbGj3LBBpPOA#16/33.6471/72.9881
and my code:
#define kMapboxMapID #"faridullah.loj1n5f3"
- (void)viewDidLoad {
[super viewDidLoad];
RMMapboxSource *onlineSource = [[RMMapboxSource alloc] initWithMapID:kMapboxMapID];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:onlineSource];
mapView.zoom = 5;
mapView.delegate = self;
mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:mapView];
mapView.showsUserLocation=YES;
}
but the markers doesnot display on device...

Just follow this example and implement the needed or delegate methods
https://www.mapbox.com/mapbox-ios-sdk/examples/marker-custom-image/

Related

How to remove the Blue and gray annotions of mapbox in iOS

How Can I Remove the user location icon defaultly shown by the map box
- (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation{
if (mapView.userTrackingMode == MGLUserTrackingModeFollow) {
return nil;
}
return Nil;
}
Hi, I have implemented this code.And I viewdidloadTried this
mapView.tintColor = [UIColor clearColor];
mapView.backgroundColor = [UIColor clearColor];
[mapView.attributionButton setTintColor:[UIColor clearColor]];
But still Showing ...
Mapbox documentation
you have configured your application’s location permissions, display the device’s current location on the map by setting the showsUserLocation property on the map view to NO
- (void)viewDidLoad {
[super viewDidLoad];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[mapView setCenterCoordinate:CLLocationCoordinate2DMake(40.74699, -73.98742)
zoomLevel:9
animated:NO];
[self.view addSubview:mapView];
mapView.styleURL = [MGLStyle satelliteStreetsStyleURL];
// Add a point annotation
MGLPointAnnotation *annotation = [[MGLPointAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(40.77014, -73.97480);
annotation.title = #"Central Park";
annotation.subtitle = #"The best park in New York City!";
[mapView addAnnotation:annotation];
// Set the map view's delegate
mapView.delegate = self;
// Allow the map view to display the user's location
mapView.showsUserLocation = NO;
}
If you check the documentation, you'll find that mapView.showsUserLocation = false should do the trick.

the #property showsIndoorMap is invalid in MAMapView of AMap3DMap Pod

- (void)viewDidLoad
{
[super viewDidLoad];
[MAMapServices sharedServices].apiKey = #"xxx";
self.mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds))];
self.mapView.delegate = self;
self.mapView.showsIndoorMap = YES;
self.mapView.showsCompass = NO;
[self.view addSubview:self.mapView];
}
I use the code above to show the map in my app. I want to use "self.mapView.showsIndoorMap = YES;" to show the indoor map but it failed. How can i see the indoor map ?

custom frame to annotation view mapbox not working

Im using mapbox and adding a custom annotation view to it. But somehow the annotation view's height is not reflecting.
Here's the code for it.
- (void)viewDidLoad {
[super viewDidLoad];
MGLMapView *mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
MGLPointAnnotation *point = [[MGLPointAnnotation alloc] init];
point.coordinate = CLLocationCoordinate2DMake(38.894368, -77.036487);
point.title = #"Hello world!";
point.subtitle = #"Welcome to The Ellipse.";
mapView.delegate = self;
[mapView setCenterCoordinate:point.coordinate zoomLevel:12 animated:NO];
[mapView addAnnotation:point];
[self.view addSubview:mapView];
// Do any additional setup after loading the view, typically from a nib.
}
-(UIView *)mapView:(MGLMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id<MGLAnnotation>)annotation
{
customAnnotationView *view = [[[NSBundle mainBundle] loadNibNamed:#"customAnnotationView" owner:self options:nil] objectAtIndex:0];
[view setFrame:CGRectMake(0, 0, 260, 100)];
return view;
}
Here the height of view is not reflecting on map.
SMCalloutView, which the Mapbox iOS SDK uses to provide annotation callouts, doesn't dynamically resize based on its child views' height. (At least, it doesn't with how Mapbox configures SMCalloutView by default).
More callout view customization is coming with v3.1.0, though!
mapView:calloutViewForAnnotation: and MGLCalloutView will allow you to completely customize the appearance.

How can I detect longtap gesture on MapBox SDK for IOS?

How can i detect longtap gesture on MapBox SDK for IOS?
I try below code.
but mapLongTap are never called.
-(void)mapInit
{
RMMBTilesSource *offlineSource = [[RMMBTilesSource alloc] initWithTileSetResource:#"tokyo5" ofType:#"mbtiles"];
mapView = [[RMMapView alloc] initWithFrame:_mapBaseView.bounds andTilesource:offlineSource];
mapView.zoom = 0;
mapView.delegate = self;
mapView.missingTilesDepth = 5;
mapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
mapView.adjustTilesForRetinaDisplay = YES;
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:#selector(mapLongTap:)];
[longPressGesture setMinimumPressDuration:1.0];
// [_mapBaseView addGestureRecognizer:longPressGesture];
[mapView addGestureRecognizer:longPressGesture];
[self.mapBaseView addSubview:mapView];
}
-(void)mapLongTap:(UISwipeGestureRecognizer *)gesture
{
NSLog(#"LongTap");
}
RMMapView already has a long press gesture recognizer. See -[RMMapViewDelegate longPressOnMap:at:].

Why does my CvVideoCamera cover the whole view?

I'm using a CvVideo Camera thus:
- (void)viewDidLoad
{
[super viewDidLoad];
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imageView];
self.videoCamera.delegate = self;
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPresetiFrame960x540;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.videoCamera start];
}
My storyboard looks like this:
When the view loads, the bar is visible briefly with the rest of the view white. Then when the camera starts it fills the whole screen. Why is it doing this?
Have you tried with a different parent view?
UIView *camView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 400)];
[self.view addSubview:camView];
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:camView];

Resources