【问题标题】:Show My Location point and one another point in single view (MKMapView)在单个视图中显示我的位置点和另一个点 (MKMapView)
【发布时间】:2012-01-05 09:22:51
【问题描述】:

我正在使用 MKMapView 并在该地图上显示特定点。

我的屏幕上有一个用于查找“我的位置”的按钮。现在我希望当我单击“我的位置”按钮时,点(我的位置和特定位置的另一个点)都应该出现在单个屏幕中。
****应该是这样的:****

------------------

所以我必须计算 myLocation(蓝色)和特定点(红色)之间的距离

有什么帮助吗?

【问题讨论】:

标签: iphone objective-c ios google-maps-api-3 mkmapview


【解决方案1】:

类似的东西……

    //create new region and set map
    CLLocationCoordinate2D coord = {latitude: yourLocation.latitude, longitude: yourLocation.longitude};
     MKCoordinateSpan span = MKCoordinateSpanMake(fabs(otherLocation.lattitude), fabs(otherLocation.longitude));
    MKCoordinateRegion region = {coord, span};
    [self.mapView setRegion:region];

【讨论】:

  • 它正在崩溃。显示原因:'无效区域 '
  • MKCoordinateSpan span = MKCoordinateSpanMake(fabs(otherLocation.lattitude), fabs(otherLocation.longitude));
  • 但是它显示了其他区域,它显示在位置 23.05319800 附近,但不是其他点。
  • 我的逻辑可能是错误的,但是看到这两个属性 region 和 span ,你需要调整它,参考文档什么的。
【解决方案2】:

如果你想在谷歌地图中显示方向,你需要当前的纬度和经度以及特定的纬度和经度,

在按钮触摸动作内

 {          
  NSURL *strlist = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",c_lat,c_long,lat,long]];
       here //c_lat = current latitude
  //c_long = current longitude
  //lat = Particular place latitude
  //long = Particular place longitude
 [[UIApplication sharedApplication]openURL:strlist];   
 }

如果你想在应用内显示方向图,

参考这篇文章

Link for Direction Tut

【讨论】:

    猜你喜欢
    • 2014-11-30
    • 2011-01-05
    • 2011-08-30
    • 2017-05-07
    • 1970-01-01
    • 2012-01-17
    • 2013-11-13
    • 2010-12-21
    • 1970-01-01
    相关资源
    最近更新 更多