Mapbox caching in ios app - ios

In the application I have some mapViews, and I want to support offline mode(caching). So: user installed app, the main screen contains mapView and it should cache it. Then user turns off the Wi-Fi and 3G, and tries to take a look at another mapView ( another viewController). It's not downloaded now. But the main screen's map is okay. Am I in the wrong way to cache?
the code for configuring the map is the same:
[[RMConfiguration sharedInstance] setAccessToken:#"pk.***"];
RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:kMapboxMapID];
[tileSource setCacheable:YES];
[self.mapView.tileCache setBackgroundCacheDelegate:self];
[self.mapView.tileCache beginBackgroundCacheForTileSource:tileSource southWest:CLLocationCoordinate2DMake(55.767363, 37.592843) northEast:CLLocationCoordinate2DMake(55.799801, 37.671229) minZoom:11 maxZoom:11];
self.mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
self.mapView.delegate=self;
[self.view addSubview:self.mapView];

If you aren't using RMTileCache's download methods to pre-fetch an area of the map, this will only work if the map area trying to be viewed in the second view controller is the same as that already viewed in the first.

Related

Overlay text on the application to show debug information

I am basically developing an iOS SDK which will be used by other apps using Cocoa pods. My question is:
Is it feasible to overlay plain text on the screens of the host app, showing them important debug information(as they use the app)? pretty much like the fps information on games screens. If yes, suggestions?
Have been searching around but all I can find are discussions around overlaying on Camera, Map and Video player, like the following:
How do i overlay a text box over a native camera view in IOS
Is it possible to add a text overlay to videos?
Change text of label in ios camera overlay UIPickercontroller
Text overlay not showing in GPUImage iOS
Any guidance in this respect would be appreciated.
Yes, should be feasible, I would add a "debug" subview to the window and set the userInteractionEnabled = NO so that view does not consume touches.
Something like this should get you started:
#if DEBUG
UILabel *debugInfo = [[UILabel alloc] init];
debugInfo.text = #"some debug information here";
debugInfo.numberOfLines = 0;
[debugInfo sizeToFit];
debugInfo.userInteractionEnabled = NO;
[[[[UIApplication sharedApplication] delegate] window]addSubview:debugInfo];
#endif

"My location button" in google map disappeared

I'am trying to add a view to google map which both have been created using the storyboard. In order to do this, I've changed this part of the code:
mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
to this:
mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
self.mapView.myLocationEnabled = YES;
[self.view insertSubview:mapView atIndex:0];
it works, but the default "My location button" disappeared after this. Is there a way to get back the default button? I would greatly appreciate any help.
I tried this solution My location button not appearing in view (Google maps SDK, ios)
but it didn't work or maybe I didn't get it correctly, if this is the only solution could you please explain it in details?
I got around this problem by creating a button from the storyboard and connect it to this action.
- (IBAction)MyLocation:(id)sender {
CLLocation *location = mapView.myLocation;
if (location) {
[mapView animateToLocation:location.coordinate];
} }
In my case, if I place the created button on the lower right/left corner still can't get it but everywhere else is just fine. (I don't know why I think because of inserting the map at index 0 or something like that).
Are you requesting access to location services correctly? It's done a bit different in iOS 8. Try adding the following to you Info.plist file and let me know if it works:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your message to request location usage permission goes here</string>

MapBox iOS SDK - First steps

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.

Mapbox polygons not displayed in ios 7 app

I have designed my required map on https://www.mapbox.com/editor/ with several polygons, however when I load the same map using the id on my ios 7 test app the map is displayed ok but the polygons are not visible/added in the ios app.
Here is the code I am using which is the sample code given on the mapbox site...
RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:#"ID_OF_MAPBOX_MAP"];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
[self.view addSubview:mapView];
Have tried many different changes but at this point I am trying to figure out if this is actually supported.
The API you want for this is -[RMMapboxSource initWithTileJSON:enablingDataOnMapView:]. However, only points are automatically supported right now. The relevant code is here if you are interested in submitting a patch, however.

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

Resources