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);
}
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();
}
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;
}
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;
}
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;
}
Aggregations