【问题标题】:download Route me online tiles into database将 Route me 在线图块下载到数据库中
【发布时间】:2014-01-06 11:41:58
【问题描述】:

在 iPhone osm 地图应用程序(Route me)上工作。初始化和下载在线地图很容易,但真正的问题在于在线时通过代码保存图块并在离线时重用它们。我查看了有关一样,但每个人都在外部保存图像并将其导入项目然后显示它们,这不是我的要求。请帮助我保存我从在线资源中选择的平铺图像路线

 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);

    }

【问题讨论】:

    标签: route-me


    【解决方案1】:

    我有一个 iOS 应用程序,它使用保存在 sqlite 数据库中的静态地图图像。有一些关于如何做到这一点的参考资料,但我花了很多时间试错才能理解它们并使其发挥作用。

    似乎您应该能够拥有一个 sqlite 数据库,并在您的应用程序下载它们时将下载的图像保存到其中。然后你必须知道要使用什么 tile 源:如果应用程序离线,则使用 sqlite 数据库,在线时使用 OSM 站点。

    数据库的结构是:
    tilekey text // route-me 用来定位正确图块的哈希值 缩放整数
    行整数
    col 整数
    缩放整数
    图像 blob 存储地图的实际图像

    我使用 Python 脚本来填充数据库,因为我希望应用始终使用数据库中的静态地图图像,而不是使用 OSM 的实时下载。

    如果您想了解更多信息,请告诉我,但如果您使用 route-me 搜索使用静态地图,您应该会找到这是如何完成的。祝你好运!

    【讨论】:

      【解决方案2】:
      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多