0

I wanted to develop tracking iOS Application , but - I wanted to load openstreetmap by using MapKit framework as Apple map doesn't provide detailed accuracy . - There are so many third party libraries/frameworks i.e. Mapbox,whirlyGlobeMaply, etc. but I dont wanted to use that. as all have pricing plans for commercial level. Also I found that Google Maps also require Pricing at commercial level. - so I have searched for many ways & I found one in following link http://www.glimsoft.com/01/31/how-to-use-openstreetmap-on-ios-7-in-7-lines-of-code/ but it shows multiple tiles - for above code i used url i.e. - "http://tile.openstreetmap.org/10/547/380.png" [which is sample map]. this gives result as follows

Screenshot for openstreetMap tile loading

  • so how to load world map tile ?? is it possible to get x,y,z co-ordinates for that??
  • or should I use offline openstreetMap ?? I have no idea how it works .
  • either it is possible or not to load OpenstreetMap by using Mapkit Framework?? or I am searching for wrong way .
  • or should I go for any paid version of third party library for Mapping functionality ???

----- Please give me suggestions, any help will be appriciable. Thanks...

Poonam K.
  • 145
  • 1
  • 1
  • 12

1 Answers1

1

As per my understanding what you need is; The whole world map in a tile.

Here is a code that I tried in past may be it can help.

Download, TileOverlay.h, TileOverlay.m, TileOverlayView.h, TileOverlayView.m files from Let's Do It

Find View Controller where you manage your MapView object. I assume that your IBOutlet MKMapView is called mapview.

ViewController.h

@interface ViewController : UIViewController <MKMapViewDelegate>


@end

ViewController.m

#import "ViewController.h"
#import "TileOverlay.h"
#import "TileOverlayView.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet MKMapView *mapview;
@property (nonatomic, retain) TileOverlay *overlay;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [super viewDidLoad];
    // your existing viewDidLoad code is here

    self.overlay = [[TileOverlay alloc] initOverlay];
    [_mapview addOverlay:self.overlay];
    MKMapRect visibleRect = [_mapview mapRectThatFits:self.overlay.boundingMapRect];
    visibleRect.size.width /= 2;
    visibleRect.size.height /= 2;
    visibleRect.origin.x += visibleRect.size.width / 2;
    visibleRect.origin.y += visibleRect.size.height / 2;
    _mapview.visibleMapRect = visibleRect;
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)ovl
{
    TileOverlayView *view = [[TileOverlayView alloc] initWithOverlay:ovl];
    view.tileAlpha = 1.0; // e.g. 0.6 alpha for semi-transparent overlay
    return view;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

Note : The files which you will get have code written with ARC disabled.It is easy to remove them just delete all the retain, release and dealloc

PrafulD
  • 548
  • 5
  • 13
  • 1
    any swift solution. I'm getting this https://stackoverflow.com/questions/51347044/why-mktileoverlay-repeats-same-tile-over-and-over-for-openstreet-map-in-ios-swi – Marlon Brando aka Ben Jul 15 '18 at 12:12