【问题标题】:Google Maps IOS SDK - Refreshing the MapView. (Objective-c)Google Maps IOS SDK - 刷新 MapView。 (目标-c)
【发布时间】:2015-04-15 23:10:44
【问题描述】:

我为 MapView 的 ViewController 创建了一个设置选项卡,当我第一次打开 MapView 的 VC 时它工作正常。但是当我在第一次打开并加载 mapView 后更改设置时,我更改的设置不适用于 mapView,因为它没有刷新。有没有办法刷新mapView的数据?我到处搜索,找不到答案。

如果这个问题之前已经回答过,你能把我链接到它吗?谢谢。

  • 我正在使用 GoogleMaps ios sdk。
  • 我正在使用 obj-c。

【问题讨论】:

  • 我什么都没尝试,因为我一开始就不知道该怎么做。 “清除并添加注释”是什么意思?

标签: ios objective-c xcode google-maps-sdk-ios


【解决方案1】:

如果您的设置只是更改图标、注释、地图标记或图层颜色或标记或图层的位置,最简单的方法是清除您在地图视图中添加的所有标记和图层并重新添加它们。比如实现一个refreshMapView方法

-(void)refreshMapView
{
    [mapView clear];//this line clears all the markers or layers you drew on the mapView.
    // then implement your method to re-draw the markers and layers, or load new settings.
    // for example, go through your marker list, and add them as follows:
    for (id yourobject in yourMarkerArray){
        GMSMarker *marker = [GMSMarker markerWithPosition:coordinatesOfMarker];
        //custom marker here, set title, or snippets, or icon, etc...
        marker.map = mapView;
    }
    // you can also redraw any map overlay here...
}

【讨论】:

    【解决方案2】:

    Jing 实现refreshMapView 方法的答案很好,您可以在地图视图控制器的viewWillAppear 部分中调用它。

    确保您实际上是在同一范围内设置 mapView 属性 - 即,您的设置视图和地图视图可能正在查看不同的对象,或者更改可能会被丢弃。如果没有看到您尝试修改这些设置的代码,很难说。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      • 2013-06-24
      • 2013-02-25
      • 2018-06-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多