菜鸟教程小白 发表于 2022-12-11 19:34:11

ios - 谷歌地图 - 获取给定半径内的所有标记


                                            <p><p>我正在开发一个 iOS 应用程序,我希望它显示给定半径内的所有标记。</p>

<p>我正在使用 GMSGeometryDistance 计算所有标记距离并返回我给定半径内的距离。</p>

<p>当前位置会频繁变化。这意味着每次更改位置时我都需要计算此值,这会影响应用性能。</p>

<p>是否有任何函数可以计算用户移动的每个给定距离?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>&lt;p&gt;
I get all the markers with in the given radius by using below code.Please check it once.Hope it will help to you. &lt;/p&gt;
&lt;p&gt;

&lt;table&gt;
&lt;tr&gt;
`CLLocationDistance dist = 800; // required radius in meters.
&lt;/tr&gt;
&lt;tr&gt;
CLLocation *closestLocation;
&lt;/tr&gt;
&lt;tr&gt;
// finalArr(NsMutableArray) stores coordinates fetching from database
&lt;/tr&gt;
&lt;tr&gt;
for (CLLocation *location in finalArr) {
&lt;/tr&gt;
&lt;tr&gt;
CLLocationDistance distance = ;
&lt;/tr&gt;
&lt;tr&gt;
      if (distance &lt; dist) {
&lt;/tr&gt;
&lt;tr&gt;
closestLocation = location;
&lt;/tr&gt;
&lt;tr&gt;
;
&lt;/tr&gt;
&lt;tr&gt;
;
&lt;/tr&gt;
&lt;tr&gt;
}
&lt;/tr&gt;
&lt;tr&gt;
for (int i=0; i&lt;; i++) {

      GMSMarker *marker = [ init];
      marker.position = CLLocationCoordinate2DMake([ doubleValue], [ doubleValue]);

      //   marker.title = ;
      marker.map = mapView;
      //NSLog(@&#34;closest loc are %@&#34;,locArr);

    }`
&lt;/tr&gt;
&lt;/table&gt;
&lt;/p&gt;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 谷歌地图 - 获取给定半径内的所有标记,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/48132936/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/48132936/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 谷歌地图 - 获取给定半径内的所有标记