Google Maps - How to get the distance between two point in metre?

后端 未结 6 505

I have these coordinate :

(45.463688, 9.18814) 
(46.0438317, 9.75936230000002)

and I need (trought Google API V3, I think) to get the dista

6条回答
  •  爱一瞬间的悲伤
    2020-11-28 23:09

    Try this

     CLLocationCoordinate2D coord1;
     coord1.latitude = 45.463688;
     coord1.longitude = 9.18814;
     CLLocation *loc1  = [[[CLLocation alloc] initWithLatitude:coord1.latitude longitude:coord1.longitude] autorelease];
    
     CLLocationCoordinate2D coord2;
     coord2.latitude = 46.0438317;
     coord2.longitude = 9.75936230000002;
     CLLocation *loc2  = [[[CLLocation alloc] initWithLatitude:46.0438317 longitude:9.75936230000002] autorelease];
    
     CLLocationDistance d1 = [loc1 distanceFromLocation:loc2];
    

提交回复
热议问题