使用iPhone osm地图应用程序(路由我).well初始化和下载在线地图很容易但真正的问题在于当你在线时通过代码保存瓷砖并在你离线时重复使用它们。我检查了关于同样但每个人都在外部保存图像并在项目中导入它然后显示它们,这不是我的要求。请帮我保存瓷砖图像路线我从在线资源中选择
here is how i am using online route me maps
-(void) viewDidLoad
{
[RMMapView class];
mapView.contents.tileSource = [[RMOpenStreetMapSource alloc] init];
currentMarker = [[RMMarker alloc]initWithUIImage:[UIImage imageNamed:@"radarLocatorLite.png"] anchorPoint:CGPointMake(0.5, 0.5)];
markerManager = [mapView markerManager];
locationManager.delegate=self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest ;
locationManager.distanceFilter =0;
[mapView.contents setZoom:17.0f];
[markerManager addMarker:currentMarker AtLatLong:currentLocation.coordinate];
[self initCompassView];
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
currentLocation =newLocation;
[mapView moveToLatLong:newLocation.coordinate];
[markerManager moveMarker:currentMarker AtLatLon: newLocation.coordinate];
[currentRoutePath addLineToLatLong:newLocation.coordinate];
[[mapView.contents overlay] addSublayer:currentRoutePath];
// NSLog(@"i reached inside location update%f",currentRoutePath.lineWidth);
}
答案 0 :(得分:1)
我有一个iOS应用程序,它使用保存在sqlite数据库中的静态地图图像。关于如何做到这一点有一些参考,但我花了很多尝试和错误的努力来理解它们并让它发挥作用。
似乎您应该能够拥有一个sqlite数据库,并在您的应用下载它们时将下载的图像保存到其中。然后你必须知道要使用哪个tile源:sqlite数据库,如果应用程序离线,OSM站点在线时。
数据库的结构是:
tilekey text // route-me用于定位正确磁贴的散列
缩放整数
行整数
col整数
缩放整数
图像blob,它存储地图的实际图像
我使用Python脚本填充数据库,因为我希望应用程序始终使用数据库中的静态地图图像,绝不使用OSM的实时下载。
如果您想了解更多信息,请告诉我,但如果您使用route-me搜索静态地图,则应该了解如何完成此操作。祝你好运!
答案 1 :(得分:0)
finally resolved problem by just a minor change in few places
Step 1: Go to this site "http://shiki.me/blog/offline-maps-in-ios-using-openstreetmap-and-route-me/" and follow instructions to download tile images from online and create of zip of the folder.remember the tile images folder are in order ->zoom level folder->x coord foler->y coord image respectively.
step 2: unzip the zip file in ur app at some folder
step 3:go to the file "RMAbstractMercatorWebSource.m" in map view project
and replace the following folders
-(NSString*) tileFile: (RMTile) tile
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Tiles"];
NSString *absPath=[NSString stringWithFormat:@"%@/%d/%d/%d.png", path,tile.zoom, tile.x, tile.y];
NSLog(@"file path >>>.............%@",absPath);
return absPath;
}//I unzipped the zip file at tiles folder
-(NSString*) tilePath
{
return nil;
}
-(RMTileImage *)tileImage:(RMTile)tile
{
RMTileImage *image;
tile = [tileProjection normaliseTile:tile];
NSString *file = [self tileFile:tile];
if(file && [[NSFileManager defaultManager] fileExistsAtPath:file])
{
image = [RMTileImage imageForTile:tile fromFile:file];
}
else if(networkOperations)
{
image = [RMTileImage imageForTile:tile withURL:[self tileURL:tile]];
}
else
{
image = [RMTileImage dummyTile:tile];
}
return image;
}
this in turns first look in cache then check the specified directory and finally go for online osm tile images