MapBox iOS SDK - First steps - ios

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!

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

Related

Here Map SDK IOS (Premium) tap on the marker

Good afternoon, who once worked with heremap sdk premium for ios. How do I make it possible to click on the NMAMapMarker? What they have written in the documentation does not describe it, but maybe I'm wrong.
there are different option available for NMAMapMarker to use.
This represents a marker used to display an icon on a geographical position on a map. The map handles proper placement of icons on the screen as well as panning and rotation.
+mapMarkerWithGeoCoordinates:
+mapMarkerWithGeoCoordinates:icon:
+mapMarkerWithGeoCoordinates:image:
coordinates
icon
draggable
draggingOffsetEnabled
anchorOffset
-initWithGeoCoordinates:
-initWithGeoCoordinates:icon:
-initWithGeoCoordinates:image:
-setAnchorOffsetUsingLayoutPosition:
-setSize:forZoomLevel:
-setSize:forZoomRange:
-resetIconSize
Check for more details : https://developer.here.com/documentation/ios-premium/3.18/api_reference_jazzy/Classes/NMAMapMarker.html#%2Fc:objc(cs)NMAMapMarker(im)initWithGeoCoordinates.
Please revert with your code implementation in case of any further concern.

How to remove an arrow from Google Maps geolocation marker (iOS)?

How do you remove an arrow from Google Maps geolocation marker (iOS)?
This is an arrow I'm talking about
If you really want to remove that arrow everywhere in your app from Google Maps SDK, it might be easiest to modify asset in GoogleMaps.framework.
Just navigate (cd) to GoogleMaps.framework/Versions/A/Resources/GoogleMaps.bundle/GMSCoreResources.bundle/ and notice the following files:
GMSSprites-0-1x.png
GMSSprites-0-2x.png
GMSSprites-0-3x.png
If you open these files, you can notice the arrow is there. So just edit directly in the asset by replacing arrow by nothing (transparent pixels).
Note: I haven't test it myself and this is not tested solution, but I believe it should work.
Disclaimer: I'm not sure, but I think this modification might violate Terms & Conditions for using the SDK. I don't get any responsibility for such modification, it's your call...
There is no way to do this with current version of the SDK (1.9.1), and actually there is an open issue with this request: Look here.
As a work around, you can hide the default button with:
_map.myLocationEnabled = NO;
Then create a custom GMSMarker
GMSMarker *pointMarker = [GMSMarker markerWithPosition:currentPosition];
pointMarker.icon = [UIImage imageNamed:#"YourImage"];
pointMarker.map = _map;
And change the position of it using a CLLocationManager, so it always show the current position. It's a bit tricky but is the only way, I could think, that you can achieve this. If you need a more complete example let me know.

Customize user location tint on iOS

I'm trying to change the color of the user location, as it is done in the "find my friends" app by Apple (see attached screenshot).
Note that I'm using the MapBox SDK, and I currently have the following method:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
}
I also looked into this thread to have an idea about how I should do something similar, but didn't find the same code for user location. Did Apple use a static PNG picture for Find my friends? Will I lose the adaptive circle around the position by changing it to another color (if that's even possible)?
UPDATE
As #Incanus said in his reply, in my -[RMMapViewDelegate mapView:layerForAnnotation:] callback method, I should get three calls corresponding to isUserLocationAnnotation = YES -- the dot, the accuracy circle, and the pulsing halo.
I only get one, and I don't get why.
Also, I tried to customise the annotation when the tracking mode changes, here's what I did:
if (self.mMapView.userTrackingMode == RMUserTrackingModeNone)
{
for (RMAnnotation *annotation in self.mMapView.annotations) {
if (annotation.isUserLocationAnnotation) {
if ([annotation.annotationType isEqualToString:#"RMAccuracyCircleAnnotation"]) {
[(RMCircle*)annotation.layer setFillColor:[[UIColor redColor] colorWithAlphaComponent:0.6]];
[(RMCircle*)annotation.layer removeAllAnimations];
}
}
}
[self enableBouncingOnLayer:self.mMapView.userLocation.layer];
}
else
{
[self.mMapView.userLocation.layer removeAnimationForKey:#"animateScale"];
}
So far so good, I get the blue accuracy circle to turn red and stop changing size.
The problem is, the MapBox framework will still update it, so it will go back to normal.
What's interesting is, using this method, I do have 3 annotation with isUserLocationAnnotation set to YES, but I only get one callback.
Any help appreciated.
In Swift 3,
mapView.tintColor = .red
Wonderfully straight forward now.
For the MapBox SDK, you can access the actual blue dot inside of the resources bundle and create a tinted version, either on the fly with Core Graphics or ahead of time as another resource in your bundle.
In Find My Friends, the dot is still blue -- they are actually just using an altered copy for other annotations. You can do the same.
You might also be interested in https://github.com/0xced/UIKit-Artwork-Extractor specifically for pulling resources out of the Find My Friends app, which is actually what we used on the MapKit framework to get the blue dot for the MapBox SDK ;-)
As Incanus pointed it out, I'm using the layerForAnnotation: method to customize my user annotation.
I then created this method to force an update of the layer, so that it can be drawn again.
- (void)refreshUserAnnotation {
[mUserAnnotation setLayer: [self mapView:mMapView layerForAnnotation:mUserAnnotation]];
}

Is there a way to change what the disclosure button in Apple Maps does?

I have tried to use MapView, but after finding out that I won't be able to add directions, I am switching to Apple Maps. At first I wanted to add a navigation bar so that I could go back to my app from Apple Maps, but I have been informed that that's not possible. So now, I want to know if I can change the page that opens when I click an annotation view disclosure button in Apple Maps, and possibly lead it back to my app that way by opening one of my local view controllers.
Apple is giving me a hard time with navigating these maps...
If it is possible, please give a code sample or something, or explain what else I can do to lead Apple Maps back to my app.
So far, I use this code to open Apple Maps:
- (IBAction)mapPressed1:(id)sender
{
CLLocationCoordinate2D miamizoo = CLLocationCoordinate2DMake(25.613336,-80.398437);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:miamizoo addressDictionary:nil];
MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark];
item.name = #"Miami Zoo";
[item openInMapsWithLaunchOptions:nil];
}
Thanks; all help is appreciated.
my initial quess is that it will not be possible because apple maps is an independent app from the one you're writing.
Apple maps is a ready, closed up application without any modification possibilities, so you will not be able to change the behavior of the disclosure button / add a bar into apple maps.
Anyone, please prove me wrong, because I also was puzzled about the missing direction feature in the map API.You will either have to use overlays for directions in map API or you bite the bullet and buy a ready made direction api for maps.
The way I'm currently doing it is similar to yours. I start up apple maps with a direction request and change into it, no overlays.
I hope they will make up for that in ios7.
They do make up for it. Didnt have the chance to put my hands on the ios7 beta, but it will be there.
El

How to set MKMapView view angle and turn off 3D building?

I am currently working on a navigation app. Is there a way to set view angle in MapKit? I know Google Map iOS SDK has it as one of parameter in viewing camera that you could set, but I wasn't able to find it in MapKit.
Also is there a bool value to turn off 3D building? They are kind of annoying for a navigation app.
Thanks in advance!
Add in viewDidLoad or viewWillAppear:
self.mapView.pitchEnabled = YES;
self.mapView.pitchEnabled = NO;
self.mapView.showsBuildings = false
(swift code) Turns off buildings.
Swift 4
mapView.settings.tiltGestures = false
Use pitch to provide viewing angle. For example, mapview.pitch or mapview.camera.pitch depending on whether you are using a camera or not. Also, set showsbuildng to NO.

Resources