【问题标题】:iOS map location with x.y带有 x.y 的 iOS 地图位置
【发布时间】:2012-11-20 20:24:24
【问题描述】:

我有一个 x,y 位置点数组。我不知道如何使用它,因为它不长/纬度。

例如:X=217338 , Y=703099

我想知道如何在 iphone SDK 上使用它以及与哪个框架一起使用?

提前致谢!

【问题讨论】:

  • 如果不是长/纬度,它们是什么格式?
  • 你已经标记了框架:它是 MapKit
  • x,y 点从何而来?来自 iphone 设备还是来自外部来源?

标签: objective-c xcode4.2 mapkit core-location latitude-longitude


【解决方案1】:

首先,您需要知道您的值的格式。
如果它们不是 lon/lat,它们可以是米或英寸或半臂长,甚至是标准化的甜甜圈孔。

无论如何,您都需要想出一种转换方法,因为MKMapKit 只了解地理坐标(经度/纬度)。

如果你已经澄清你应该看看苹果的location awarness guide。还有一些其他很好的 mapkit 资源,例如 raywenderlich.com

【讨论】:

    【解决方案2】:

    在不知道这些值代表什么的情况下,您实际上无能为力。假设您可以将它们转换为纬度/经度值,这就是您能够以 (X, Y) 坐标为中心的方式:

    //Import the <MapKit/MapKit.h> and <CoreLocation/CoreLocation.h> framework 
    //and then this will go in your implementation file:
    CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(xConvertedToLat, yConvertedToLong);
    //Set the region your map will display centered on the above coord and spanning 250m on x-axis and 250 on y-axis
    MKCoordinateRegion region = MKCoordinateRegionMake(coord, 250, 250);
    //You should have a MKMapView object
    [myMapView setRegion:region animated:YES];
    

    您可以对数组中的每个对象进行迭代,但在设置最后一个 (x, y) 坐标之前,您不会看到任何内容。

    【讨论】:

      猜你喜欢
      • 2017-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多