Search in sources :

Example 1 with Polygon

use of org.osmdroid.views.overlay.Polygon in project Telegram-FOSS by Telegram-FOSS-Team.

the class LocationActivity method createCircle.

private void createCircle(int meters) {
    if (mapView == null) {
        return;
    }
    proximityCircleCenter = new GeoPoint(myLocation.getLatitude(), myLocation.getLongitude());
    proximityCircleRadius = meters;
    proximityCircle = new Polygon();
    proximityCircle.setPoints(Polygon.pointsAsCircle(proximityCircleCenter, meters));
    if (isActiveThemeDark()) {
        proximityCircle.getOutlinePaint().setColor(0x9666A3D7);
        proximityCircle.getFillPaint().setColor(0x1c66A3D7);
    } else {
        proximityCircle.getOutlinePaint().setColor(0x964286F5);
        proximityCircle.getFillPaint().setColor(0x1c4286F5);
    }
    // TODO: set dash /gap
    proximityCircle.getOutlinePaint().setStrokeWidth(2);
    mapView.getOverlayManager().add(proximityCircle);
}
Also used : IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) Polygon(org.osmdroid.views.overlay.Polygon)

Example 2 with Polygon

use of org.osmdroid.views.overlay.Polygon 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 3 with Polygon

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

the class KmlPolygon method buildOverlay.

/**
 * Build the corresponding Polygon overlay
 */
@Override
public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, KmlDocument kmlDocument) {
    Polygon polygonOverlay = new Polygon();
    polygonOverlay.setPoints(mCoordinates);
    if (mHoles != null)
        polygonOverlay.setHoles(mHoles);
    polygonOverlay.setTitle(kmlPlacemark.mName);
    polygonOverlay.setSnippet(kmlPlacemark.mDescription);
    polygonOverlay.setSubDescription(kmlPlacemark.getExtendedDataAsText());
    polygonOverlay.setRelatedObject(this);
    polygonOverlay.setId(mId);
    if (styler == null)
        applyDefaultStyling(polygonOverlay, defaultStyle, kmlPlacemark, kmlDocument, map);
    else
        styler.onPolygon(polygonOverlay, kmlPlacemark, this);
    return polygonOverlay;
}
Also used : Polygon(org.osmdroid.views.overlay.Polygon)

Example 4 with Polygon

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

the class MainActivity method longPressHelper.

@Override
public boolean longPressHelper(GeoPoint p) {
    // Toast.makeText(this, "Long press", Toast.LENGTH_SHORT).show();
    // 17. Using Polygon, defined as a circle:
    Polygon circle = new Polygon();
    circle.setPoints(Polygon.pointsAsCircle(p, 10000.0));
    circle.getFillPaint().setColor(0x12121212);
    circle.getOutlinePaint().setColor(Color.RED);
    circle.getOutlinePaint().setStrokeWidth(2);
    map.getOverlays().add(circle);
    circle.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
    circle.setTitle("Centered on " + p.getLatitude() + "," + p.getLongitude());
    // 18. Using GroundOverlay
    /*
		GroundOverlay myGroundOverlay = new GroundOverlay();
		myGroundOverlay.setPosition(p);
		Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_launcher, null);
		myGroundOverlay.setImage(d.mutate());
		myGroundOverlay.setDimensions(2000.0f);
		//myGroundOverlay.setTransparency(0.25f);
		myGroundOverlay.setBearing(mGroundOverlayBearing);
		mGroundOverlayBearing += 20.0f;
		map.getOverlays().add(myGroundOverlay);
		*/
    /*
		Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.bonuspack_bubble_black, null);
		myGroundOverlay.setImage(d.mutate());
		BoundingBox bb = new BoundingBox(p.getLatitude()+map.getLatitudeSpanDouble()/2,
				p.getLongitude()+map.getLongitudeSpanDouble()/2,
				p.getLatitude(),
				p.getLongitude());
		myGroundOverlay.setPositionFromBounds(bb);
		map.getOverlays().add(myGroundOverlay);

		Marker ne = new Marker(map);
		ne.setPosition(new GeoPoint(bb.getLatNorth(), bb.getLonEast()));
		ne.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
		map.getOverlays().add(ne);
		Marker sw = new Marker(map);
		sw.setPosition(new GeoPoint(bb.getLatSouth(), bb.getLonWest()));
		sw.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
		map.getOverlays().add(sw);
		*/
    map.invalidate();
    return true;
}
Also used : BasicInfoWindow(org.osmdroid.views.overlay.infowindow.BasicInfoWindow) Polygon(org.osmdroid.views.overlay.Polygon) KmlPolygon(org.osmdroid.bonuspack.kml.KmlPolygon)

Example 5 with Polygon

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

the class KmlFolder method addOverlay.

/**
 * Converts the overlay to a KmlFeature and add it inside this.
 * Conversion from Overlay subclasses to KML Features is as follow: <br>
 *   FolderOverlay, MarkerClusterer => Folder<br>
 *   Marker => Point<br>
 *   Polygon => Polygon<br>
 *   Polyline => LineString<br>
 *   GroundOverlay => GroundOverlay<br>
 *   Else, add nothing.
 * @param overlay to convert and add
 * @param kmlDoc for style handling.
 * @return true if OK, false if the overlay has not been added.
 */
public boolean addOverlay(Overlay overlay, KmlDocument kmlDoc) {
    if (overlay == null)
        return false;
    KmlFeature kmlItem;
    if (overlay instanceof GroundOverlay) {
        kmlItem = new KmlGroundOverlay((GroundOverlay) overlay);
    } else if (overlay instanceof FolderOverlay) {
        kmlItem = new KmlFolder((FolderOverlay) overlay, kmlDoc);
    } else if (overlay instanceof MarkerClusterer) {
        kmlItem = new KmlFolder((MarkerClusterer) overlay, kmlDoc);
    } else if (overlay instanceof Marker) {
        Marker marker = (Marker) overlay;
        kmlItem = new KmlPlacemark(marker);
    } else if (overlay instanceof Polygon) {
        Polygon polygon = (Polygon) overlay;
        kmlItem = new KmlPlacemark(polygon, kmlDoc);
    } else if (overlay instanceof Polyline) {
        Polyline polyline = (Polyline) overlay;
        kmlItem = new KmlPlacemark(polyline, kmlDoc);
    } else {
        return false;
    }
    mItems.add(kmlItem);
    return true;
}
Also used : Polyline(org.osmdroid.views.overlay.Polyline) FolderOverlay(org.osmdroid.views.overlay.FolderOverlay) Marker(org.osmdroid.views.overlay.Marker) Polygon(org.osmdroid.views.overlay.Polygon) MarkerClusterer(org.osmdroid.bonuspack.clustering.MarkerClusterer) GroundOverlay(org.osmdroid.bonuspack.overlays.GroundOverlay)

Aggregations

Polygon (org.osmdroid.views.overlay.Polygon)5 GeoPoint (org.osmdroid.util.GeoPoint)2 FolderOverlay (org.osmdroid.views.overlay.FolderOverlay)2 Paint (android.graphics.Paint)1 IGeoPoint (org.osmdroid.api.IGeoPoint)1 MarkerClusterer (org.osmdroid.bonuspack.clustering.MarkerClusterer)1 KmlPoint (org.osmdroid.bonuspack.kml.KmlPoint)1 KmlPolygon (org.osmdroid.bonuspack.kml.KmlPolygon)1 GroundOverlay (org.osmdroid.bonuspack.overlays.GroundOverlay)1 BoundingBox (org.osmdroid.util.BoundingBox)1 MapEventsOverlay (org.osmdroid.views.overlay.MapEventsOverlay)1 Marker (org.osmdroid.views.overlay.Marker)1 Overlay (org.osmdroid.views.overlay.Overlay)1 Polyline (org.osmdroid.views.overlay.Polyline)1 ScaleBarOverlay (org.osmdroid.views.overlay.ScaleBarOverlay)1 TilesOverlay (org.osmdroid.views.overlay.TilesOverlay)1 BasicInfoWindow (org.osmdroid.views.overlay.infowindow.BasicInfoWindow)1 DirectedLocationOverlay (org.osmdroid.views.overlay.mylocation.DirectedLocationOverlay)1