How to add custom map source to route-me?
'route-me' is an iPhone map engine and I want to add my own map source to 开发者_StackOverflow社区it. I've got all the map images on my server but I dont know how to add the map source? Any one could help?
There seems to be two ways to do this:
First, from the documentation:
If you have your own maps, you can use Mapnik as a framework and OpenStreetMap as your host. You can then point to your map with the RMOpenStreetMapsSource
class to specify the URL.
Alternatively,
You can use an app for route-this called SimpleMap along with an extension called Map2sqlite. This allows you to use a class caled RMDBTileSource
and point to a sqlite DB file of your maps as the source. I found this tidbit on a google groups article covering this topic.
google maps in route-me example:
in RegionGmapTile.h
#import <Foundation/Foundation.h>
#import "RMAbstractMercatorWebSource.h"
@interface RegionGmapTile : RMAbstractMercatorWebSource
{
}
@end
in RegionGmapTile.m
#import "RegionGmapTile.h"
@implementation RegionGmapTile
-(NSString*) tileURL: (RMTile) tile
{
NSString* url = [NSString stringWithFormat:@"http://mt0.google.com/vt/lyrs=m@127&x=%d&y=%d&z=%d",tile.x, tile.y,tile.zoom];
return url;
}
-(NSString*) uniqueTilecacheKey
{
return @"NLSHistoricMap";
}
-(NSString *)shortName
{
return @"NLS Historic Map";
}
-(NSString *)longDescription
{
return @"NLS Historic Map Test";
}
-(NSString *)shortAttribution
{
return @"Google maps";
}
-(NSString *)longAttribution
{
return @"Google maps";
}
@end
somwehere in your route-me
[[RMMapContents alloc] initForView:mvMap];
mvMap.contents.tileSource = [[RegionGmapTile alloc] init];
and google maps are shown without any key
So, code below should get the job done?
id <RMTileSource> tileSource;
NSURL *mapURL = [NSURL URLWithString:@"myOSM_URL"];
tileSource = [[[RMOpenStreetMapSource alloc] initWithURL:mapURL] autorelease];
Doing this results with error:
-[RMOpenStreetMapSource initWithURL:]: unrecognized selector sent to instance 0x5b0c310
精彩评论