0

I have been working with osmdroidbonus but with the example I have to display complete information like name and description. I want to display only the name not the description. And is it possible to store the value of mname in some variable ?

//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);*/
        }
    }
techno
  • 101
  • 1
  • 1
  • 8

1 Answers1

0

"I want to display only the name not the description." => in fact, description is not set. Only the sub-description is set. From KML tags. So a possible solution: after overpassProvider.addInKmlFolder, and before building the overlays, loop through mKmlDocument.mKmlRoot placemarks, and remove the Extended Data of each placemark (thePlacemark.mExtendedData = null).

"is it possible to store the value of mname in some variable ?" => Please clarify your need.

MKer
  • 3,430
  • 1
  • 13
  • 18
  • can you explain the solution in more detail. I am just getting started with osmdroid and osmbonus pack . "is it possible to store the value of mname in some variable ?" => Please clarify your need. I want to store the name and description which is displayed when tapped on the marker in some String variable so that i could manupulate it. – techno Nov 22 '16 at 03:56
  • They are already stored in String variables, and you can already manipulate them... Try to be more explicit on what you want to achieve. – MKer Nov 25 '16 at 21:17