繁体   English   中英

如何添加自定义地图源到路由我?

[英]How to add custom map source to route-me?

'route-me'是一个iPhone地图引擎,我想添加自己的地图源。 我在我的服务器上有所有的地图图像,但我不知道如何添加地图源? 任何人都可以帮忙吗?

似乎有两种方法可以做到这一点:

首先,从文档:

如果您有自己的地图,可以使用Mapnik作为框架,使用OpenStreetMap作为主机。 然后,您可以使用RMOpenStreetMapsSource类指向您的地图以指定URL。

或者,

您可以使用应用程序进行路由 - 这称为SimpleMap以及名为Map2sqlite的扩展。 这允许您使用类别为RMDBTileSource并指向您的地图的sqlite DB文件作为源。 我在一篇关于这个主题谷歌小组文章中找到了这个小窍门

在路线我的谷歌地图示例:

在RegionGmapTile.h中

#import <Foundation/Foundation.h>
#import "RMAbstractMercatorWebSource.h"

@interface RegionGmapTile : RMAbstractMercatorWebSource 
{    
}

@end

在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

在你的路线上,我是一个人

[[RMMapContents alloc] initForView:mvMap];

mvMap.contents.tileSource = [[RegionGmapTile alloc] init];

和谷歌地图显示没有任何键

那么,下面的代码应该完成工作?

id <RMTileSource> tileSource;
NSURL *mapURL = [NSURL URLWithString:@"myOSM_URL"];
tileSource = [[[RMOpenStreetMapSource alloc] initWithURL:mapURL] autorelease];

这样做会导致错误:

-[RMOpenStreetMapSource initWithURL:]: unrecognized selector sent to instance 0x5b0c310

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM