在单个视图中显示我的位置点和另一个点(MKMapView)

时间:2011-11-24 06:47:30

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

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

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

------------------------------ enter image description here

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

请帮忙吗?

2 个答案:

答案 0 :(得分:0)

如果你想在谷歌地图中显示方向,你需要当前的纬度&经度和特殊的地方lat&长,

在按钮触摸操作中

 {          
  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];   
 }

如果你想在app中显示方向图,

请参阅此内容

Link for Direction Tut

答案 1 :(得分:0)

类似的东西......

    //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];