【问题标题】:Get placemark from getPlacemarks with Google Maps Android API utility library使用 Google Maps Android API 实用程序库从 getPlacemarks 获取地标
【发布时间】:2016-05-14 05:19:21
【问题描述】:

我正在使用this library 在 Android Maps V2 的地图中显示 kml 标记。 我正在尝试从 kml 图层获取纬度和经度,以便在将其添加到地图后直接缩放到地标。

我尝试过这样做:

 layer = new KmlLayer(mMap,R.raw.ruta, this );
 layer.addLayerToMap();
 for (KmlPlacemark act : layer.getPlacemarks()){
      System.out.println("hi");//not iterate
 }

但它没有进入循环我读了这个kml-feature,但没有按原样工作

【问题讨论】:

    标签: android kml android-maps-v2


    【解决方案1】:

    在尝试读取有关地标的信息之前,您必须先读取 KML 层的第一个容器:

    KmlContainer = layer.getContainers().iterator().next();
    if (kmlContainer == null) return;
    
    for (KmlPlacemarks placemark : kmlContainer.getPlacemarks()) {
      // Do the placemark magic here!
    }
    

    【讨论】:

    • 好的,我马上试试
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 1970-01-01
    相关资源
    最近更新 更多