MKergall / osmbonuspack

A third-party library of (very) useful additional objects for osmdroid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to draw routes from current location to first point in KML ?

hosnyDev opened this issue · comments

This my code to get kml (url)

    kmlDocument = new KmlDocument();
    kmlDocument.parseKMLUrl(getKmlNameFile());

    Drawable currentDraw = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_kml_point, null);
    Style defaultStyle = new Style(convertDrawableToBitmap(currentDraw), 0x901010AA, 3.0f, 0x20AA1010);

    FolderOverlay kmlOverlay = (FolderOverlay) kmlDocument.mKmlRoot.buildOverlay(map, defaultStyle, null, kmlDocument);

    map.getOverlays().add(kmlOverlay);

And this my code to get current location

    GpsMyLocationProvider provider = new GpsMyLocationProvider(this);
    provider.setLocationUpdateMinDistance(100); // [m]  // Set the minimum distance for location updates
    provider.setLocationUpdateMinTime(10000);   // [ms] // Set the minimum time interval for
    provider.addLocationSource(LocationManager.GPS_PROVIDER);

    myLocationOverlay = new MyLocationNewOverlay(provider, map);
    myLocationOverlay.enableFollowLocation(); //to follow user location
    myLocationOverlay.enableMyLocation(); //to enable location
    myLocationOverlay.setDrawAccuracyEnabled(true);

    //to draw icon on current location
    Drawable currentDraw = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_menu_mylocation, null);

    myLocationOverlay.setDirectionArrow(convertDrawableToBitmap(currentDraw), convertDrawableToBitmap(currentDraw));

    map.getOverlays().add(myLocationOverlay);

    BoundingBox bb = myLocationOverlay.getBounds();
    map.getController().setCenter(bb.getCenterWithDateLine());

    map.invalidate();

Can anyone help me??

commented

Request for help: on StackOverflow please.
(and with an explicit question)