Ios 谷歌地图-获取给定半径内的所有标记
我正在处理一个iOS应用程序,我希望它显示给定半径内的所有标记 我使用GMSGeometryDistance计算所有标记距离,并返回给定半径内的标记距离 当前位置以高频变化。这意味着每次更改位置时,我都需要计算该值,这会影响应用程序的性能 是否有任何函数可以计算用户移动的每个给定距离?Ios 谷歌地图-获取给定半径内的所有标记,ios,api,google-maps,maps,Ios,Api,Google Maps,Maps,我正在处理一个iOS应用程序,我希望它显示给定半径内的所有标记 我使用GMSGeometryDistance计算所有标记距离,并返回给定半径内的标记距离 当前位置以高频变化。这意味着每次更改位置时,我都需要计算该值,这会影响应用程序的性能 是否有任何函数可以计算用户移动的每个给定距离? <p> I get all the markers with in the given radius by using below code.Please check it once.Hope it
<p>
I get all the markers with in the given radius by using below code.Please check it once.Hope it will help to you. </p>
<p>
<table>
<tr>
`CLLocationDistance dist = 800; // required radius in meters.
</tr>
<tr>
CLLocation *closestLocation;
</tr>
<tr>
// finalArr(NsMutableArray) stores coordinates fetching from database
</tr>
<tr>
for (CLLocation *location in finalArr) {
</tr>
<tr>
CLLocationDistance distance = [currentLoc distanceFromLocation:location];
</tr>
<tr>
if (distance < dist) {
</tr>
<tr>
closestLocation = location;
</tr>
<tr>
[closeLatArr addObject:@(closestLocation.coordinate.latitude)];
</tr>
<tr>
[closeLongArr addObject:@(closestLocation.coordinate.longitude)];
</tr>
<tr>
}
</tr>
<tr>
for (int i=0; i<[closeLatArr count]; i++) {
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([[closeLatArr objectAtIndex:i] doubleValue], [[closeLongArr objectAtIndex:i] doubleValue]);
// marker.title = [locArr objectAtIndex:i];
marker.map = mapView;
//NSLog(@"closest loc are %@",locArr);
}`
</tr>
</table>
</p>
我使用下面的代码获得了给定半径内的所有标记。请检查一次。希望对您有所帮助
`CLLOCATIONDIST=800;//所需半径(米)。
CLLocation*闭合位置;
//finalArr(NsMutableArray)存储从数据库获取的坐标
用于(CLLocation*最终位置){
CLLocationDistance distance=[currentLoc distanceFromLocation:location];
if(距离<距离){
闭合位置=位置;
[closeLatArr添加对象:@(ClosesLocation.coordinate.latitude)];
[closeLongArr addObject:@(closesLocation.coordinate.longitude)];
}
对于(int i=0;i