按下标记时如何才显示名称?

时间:2016-11-21 07:48:54

标签: android openstreetmap osmdroid overpass-api

我一直在使用osmdroidbonus但是在示例中我必须显示完整的信息,如名称和描述。 我想只显示名称而不是说明。 是否可以将mname的值存储在某个变量中?

//Get OpenStreetMap content as KML with Overpass API:
    OverpassAPIProvider overpassProvider = new OverpassAPIProvider();
    BoundingBox oBB = new BoundingBox(startPoint.getLatitude() + 0.25, startPoint.getLongitude() + 0.25,
            startPoint.getLatitude() - 0.25, startPoint.getLongitude() - 0.25);
    String oUrl = overpassProvider.urlForTagSearchKml("amenity="+school, oBB, 100, 100);
    boolean ok = overpassProvider.addInKmlFolder(mKmlDocument.mKmlRoot, oUrl);



    if (ok) {

        //13.1 Simple styling
        Drawable defaultMarker = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_kml_point, null);
        Bitmap defaultBitmap = ((BitmapDrawable) defaultMarker).getBitmap();
        Style defaultStyle = new Style(defaultBitmap, 0x911010AA, 50.0f, 0x20CC1010);
        //13.2 Advanced styling with Styler
        KmlFeature.Styler styler = new MyKmlStyler(defaultStyle);

        FolderOverlay kmlOverlay = (FolderOverlay) mKmlDocument.mKmlRoot.buildOverlay(map, defaultStyle, styler, mKmlDocument);



        map.getOverlays().add(kmlOverlay);

        BoundingBox bb = mKmlDocument.mKmlRoot.getBoundingBox();


        if (bb != null) {
            //map.zoomToBoundingBox(bb, false); //=> not working in onCreate - this is a well-known osmdroid issue.
            //Workaround:
            setInitialViewOn(bb);
           /* String a = mKmlDocument.mKmlRoot.mName;
            Log.d(TAG,a);*/
        }
    }

1 个答案:

答案 0 :(得分:0)

"我想只显示名称而不是描述。" =>实际上,没有设置描述。仅设置子描述。来自KML标签。 这是一个可能的解决方案:在overpassProvider.addInKmlFolder之后,在构建叠加层之前,循环遍历mKmlDocument.mKmlRoot地标,并删除每个地标的扩展数据(thePlacemark.mExtendedData = null)。

"是否可以将mname的值存储在某个变量中?" =>请澄清您的需求。