ios - 显示位置并在 ios 中找到最近的位置
<p><p>我想显示我的点 <code>NSArray *chSpot = ;</code>
接收 3 个对象,我想显示每个位置的经纬度 <a href="/image/z6Hr5.png" rel="noreferrer noopener nofollow"><img src="/image/z6Hr5.png" alt="enter image description here"/></a> </p>
<p>并根据我的位置找到最近的地点...我正在使用此代码:</p>
<pre><code> NSArray *chSpot = ;
</code></pre>
<p>//GMSCameraPosition *camera =
//经度:
//缩放:4];</p>
<pre><code> mapView_ = ;
mapView_.myLocationEnabled = YES;
mapView_.settings.myLocationButton = YES;
for (int i=0; i<chSpot.count; i++)
{
ChargingSpots *spot = ;
NSString *locLat = spot.LocationLat;
NSString *locLong = spot.LocationLong;
// Creates a marker in the center of the map.
GMSMarker *marker = [ init];
marker.position = CLLocationCoordinate2DMake(, );
marker.title = @"Amman";
marker.snippet = @"Jordan";
mapView_.delegate=self;
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.icon = ;
marker.map = mapView_;
}
//;
self.view = mapView_;
</code></pre>
<p>//<br/>
//<br/>
//CLLocation *locationA = [ initWithLatitude: longitude:];
//<br/>
//CLLocation *locationB = [ initWithLatitude: longitude:];
//<br/>
//CLLocationDistance distance = [ locationA distanceFromLocation:locationB];
//<br/>
//NSLog (@"%f",distance);</p>
<pre><code> self.locationManager = [ init];
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 locationManager 的委托(delegate)方法 <code>locationManager:didUpdateLocations:</code> 中,您可以获得当前位置,它提供了计算 distanceFromLocation:(const CLLocation *)location 的方法</p>
<p><code>CLLocationDistance distA = ;</code>
<code>CLLocationDistance distB = ;//等等</code></p></p>
<p style="font-size: 20px;">关于ios - 显示位置并在 ios 中找到最近的位置,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32477399/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32477399/
</a>
</p>
页:
[1]