Search in sources :

Example 1 with Overlay

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

the class MapActivity method updateUIWithPolygon.

// add or replace the polygon overlay
public void updateUIWithPolygon(ArrayList<GeoPoint> polygon, String name) {
    List<Overlay> mapOverlays = map.getOverlays();
    int location = -1;
    if (mDestinationPolygon != null)
        location = mapOverlays.indexOf(mDestinationPolygon);
    mDestinationPolygon = new Polygon();
    mDestinationPolygon.setFillColor(0x15FF0080);
    mDestinationPolygon.setStrokeColor(0x800000FF);
    mDestinationPolygon.setStrokeWidth(5.0f);
    mDestinationPolygon.setTitle(name);
    BoundingBox bb = null;
    if (polygon != null) {
        mDestinationPolygon.setPoints(polygon);
        bb = BoundingBox.fromGeoPoints(polygon);
    }
    if (location != -1)
        mapOverlays.set(location, mDestinationPolygon);
    else
        // insert just above the MapEventsOverlay.
        mapOverlays.add(1, mDestinationPolygon);
    setViewOn(bb);
    map.invalidate();
}
Also used : BoundingBox(org.osmdroid.util.BoundingBox) 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) Polygon(org.osmdroid.views.overlay.Polygon) KmlPoint(org.osmdroid.bonuspack.kml.KmlPoint) Paint(android.graphics.Paint) GeoPoint(org.osmdroid.util.GeoPoint)

Example 2 with Overlay

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

the class FolderZOverlay method draw.

// TODO:
// get highest z-index => getMaxZIndex
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (shadow)
        return;
    Iterator<ZOverlay> itr = mList.iterator();
    while (itr.hasNext()) {
        ZOverlay item = itr.next();
        Overlay overlay = item.mOverlay;
        if (overlay != null && overlay.isEnabled()) {
            if (item.shouldBeDrawn(mapView.getBoundingBox(), mapView.getMapOrientation())) {
                overlay.draw(canvas, mapView, false);
            }
        }
    }
}
Also used : Overlay(org.osmdroid.views.overlay.Overlay)

Example 3 with Overlay

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

the class KmlMultiGeometry method buildOverlay.

/**
 * Build a FolderOverlay containing all overlays from this MultiGeometry items
 */
@Override
public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, KmlDocument kmlDocument) {
    FolderOverlay folderOverlay = new FolderOverlay();
    for (KmlGeometry k : mItems) {
        Overlay overlay = k.buildOverlay(map, defaultStyle, styler, kmlPlacemark, kmlDocument);
        folderOverlay.add(overlay);
    }
    return folderOverlay;
}
Also used : FolderOverlay(org.osmdroid.views.overlay.FolderOverlay) Overlay(org.osmdroid.views.overlay.Overlay) FolderOverlay(org.osmdroid.views.overlay.FolderOverlay)

Example 4 with Overlay

use of org.osmdroid.views.overlay.Overlay in project collect by opendatakit.

the class GeoTraceOsmMapActivityTest method testLocationClientLifecycle.

@Test
public void testLocationClientLifecycle() {
    activityController.create();
    activityController.start();
    verify(locationClient).start();
    when(locationClient.isLocationAvailable()).thenReturn(true);
    ArrayList<Overlay> overlays = new ArrayList<>();
    when(mapView.getOverlays()).thenReturn(overlays);
    // When the LocationClient starts, add the overlay and enable location:
    activity.onClientStart();
    verify(locationClient).requestLocationUpdates(activity);
    assertFalse(overlays.isEmpty());
    verify(locationOverlay).setEnabled(true);
    verify(locationOverlay).enableMyLocation();
    activity.setModeActive(true);
    GeoPoint geoPoint = mock(GeoPoint.class);
    when(locationOverlay.getMyLocation()).thenReturn(geoPoint);
    activity.onLocationChanged(newMockLocation());
    verify(mapController).setCenter(geoPoint);
    activityController.stop();
    verify(locationClient).stop();
}
Also used : GeoPoint(org.osmdroid.util.GeoPoint) ArrayList(java.util.ArrayList) MyLocationNewOverlay(org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay) Overlay(org.osmdroid.views.overlay.Overlay) Test(org.junit.Test)

Example 5 with Overlay

use of org.osmdroid.views.overlay.Overlay in project iGap-Android by KianIranian-STDG.

the class FragmentiGapMap method clickDrawMarkActive.

/**
 * activation map for show mark after each tap
 */
private void clickDrawMarkActive() {
    Overlay touchOverlay = new Overlay() {

        ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = null;

        @Override
        public void draw(Canvas arg0, MapView arg1, boolean arg2) {
        }

        @Override
        public boolean onSingleTapConfirmed(final MotionEvent e, final MapView mapView) {
            drawMark(e, mapView);
            return true;
        }

        @Override
        public boolean onLongPress(MotionEvent e, MapView mapView) {
            // drawMark(e, mapView);
            return super.onLongPress(e, mapView);
        }
    };
    map.getOverlays().add(touchOverlay);
}
Also used : Canvas(android.graphics.Canvas) MapView(org.osmdroid.views.MapView) ItemizedIconOverlay(org.osmdroid.views.overlay.ItemizedIconOverlay) CompassOverlay(org.osmdroid.views.overlay.compass.CompassOverlay) ItemizedOverlay(org.osmdroid.views.overlay.ItemizedOverlay) ItemizedIconOverlay(org.osmdroid.views.overlay.ItemizedIconOverlay) Overlay(org.osmdroid.views.overlay.Overlay) MotionEvent(android.view.MotionEvent)

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