Search in sources :

Example 6 with Overlay

use of org.osmdroid.views.overlay.Overlay in project osmbonuspack by MKergall.

the class MapActivity method updateUIWithRoads.

void updateUIWithRoads(Road[] roads) {
    mRoadNodeMarkers.getItems().clear();
    TextView textView = (TextView) findViewById(R.id.routeInfo);
    textView.setText("");
    List<Overlay> mapOverlays = map.getOverlays();
    if (mRoadOverlays != null) {
        for (int i = 0; i < mRoadOverlays.length; i++) mapOverlays.remove(mRoadOverlays[i]);
        mRoadOverlays = null;
    }
    if (roads == null)
        return;
    if (roads[0].mStatus == Road.STATUS_TECHNICAL_ISSUE)
        Toast.makeText(map.getContext(), "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
    else if (// functional issues
    roads[0].mStatus > Road.STATUS_TECHNICAL_ISSUE)
        Toast.makeText(map.getContext(), "No possible route here", Toast.LENGTH_SHORT).show();
    mRoadOverlays = new Polyline[roads.length];
    for (int i = 0; i < roads.length; i++) {
        Polyline roadPolyline = RoadManager.buildRoadOverlay(roads[i]);
        mRoadOverlays[i] = roadPolyline;
        if (mWhichRouteProvider == GRAPHHOPPER_BICYCLE || mWhichRouteProvider == GRAPHHOPPER_PEDESTRIAN) {
            Paint p = roadPolyline.getPaint();
            p.setPathEffect(new DashPathEffect(new float[] { 10, 5 }, 0));
        }
        String routeDesc = roads[i].getLengthDurationText(this, -1);
        roadPolyline.setTitle(getString(R.string.route) + " - " + routeDesc);
        roadPolyline.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
        roadPolyline.setRelatedObject(i);
        roadPolyline.setOnClickListener(new RoadOnClickListener());
        mapOverlays.add(1, roadPolyline);
    // we insert the road overlays at the "bottom", just above the MapEventsOverlay,
    // to avoid covering the other overlays.
    }
    selectRoad(0);
}
Also used : BasicInfoWindow(org.osmdroid.views.overlay.infowindow.BasicInfoWindow) Polyline(org.osmdroid.views.overlay.Polyline) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) DashPathEffect(android.graphics.DashPathEffect) Paint(android.graphics.Paint) TilesOverlay(org.osmdroid.views.overlay.TilesOverlay) ScaleBarOverlay(org.osmdroid.views.overlay.ScaleBarOverlay) DirectedLocationOverlay(org.osmdroid.views.overlay.mylocation.DirectedLocationOverlay) FolderOverlay(org.osmdroid.views.overlay.FolderOverlay) MapEventsOverlay(org.osmdroid.views.overlay.MapEventsOverlay) Overlay(org.osmdroid.views.overlay.Overlay) KmlPoint(org.osmdroid.bonuspack.kml.KmlPoint) Paint(android.graphics.Paint) GeoPoint(org.osmdroid.util.GeoPoint)

Example 7 with Overlay

use of org.osmdroid.views.overlay.Overlay in project osmbonuspack by MKergall.

the class KmlFolder method buildOverlay.

/**
 * Build a FolderOverlay, containing (recursively) overlays from all items of this Folder.
 * @param map
 * @param defaultStyle to apply when an item has no Style defined.
 * @param styler to apply
 * @param kmlDocument for Styles
 * @return the FolderOverlay built
 */
@Override
public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlDocument kmlDocument) {
    FolderOverlay folderOverlay = new FolderOverlay();
    folderOverlay.setName(mName);
    folderOverlay.setDescription(mDescription);
    for (KmlFeature k : mItems) {
        Overlay overlay = k.buildOverlay(map, defaultStyle, styler, kmlDocument);
        if (overlay != null)
            folderOverlay.add(overlay);
    }
    if (styler == null)
        folderOverlay.setEnabled(mVisibility);
    else
        styler.onFeature(folderOverlay, this);
    return folderOverlay;
}
Also used : FolderOverlay(org.osmdroid.views.overlay.FolderOverlay) GroundOverlay(org.osmdroid.bonuspack.overlays.GroundOverlay) Overlay(org.osmdroid.views.overlay.Overlay) FolderOverlay(org.osmdroid.views.overlay.FolderOverlay)

Aggregations

Overlay (org.osmdroid.views.overlay.Overlay)7 FolderOverlay (org.osmdroid.views.overlay.FolderOverlay)4 GeoPoint (org.osmdroid.util.GeoPoint)3 Paint (android.graphics.Paint)2 KmlPoint (org.osmdroid.bonuspack.kml.KmlPoint)2 MapEventsOverlay (org.osmdroid.views.overlay.MapEventsOverlay)2 ScaleBarOverlay (org.osmdroid.views.overlay.ScaleBarOverlay)2 TilesOverlay (org.osmdroid.views.overlay.TilesOverlay)2 DirectedLocationOverlay (org.osmdroid.views.overlay.mylocation.DirectedLocationOverlay)2 Canvas (android.graphics.Canvas)1 DashPathEffect (android.graphics.DashPathEffect)1 MotionEvent (android.view.MotionEvent)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 GroundOverlay (org.osmdroid.bonuspack.overlays.GroundOverlay)1 BoundingBox (org.osmdroid.util.BoundingBox)1 MapView (org.osmdroid.views.MapView)1 ItemizedIconOverlay (org.osmdroid.views.overlay.ItemizedIconOverlay)1