use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.
the class FavoritesTreeFragment method selectMapMarkersImpl.
private void selectMapMarkersImpl() {
if (getSelectedFavoritesCount() > 0) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
List<LatLon> points = new ArrayList<>();
List<PointDescription> names = new ArrayList<>();
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
FavoriteGroup favGr = helper.getGroup(entry.getKey());
MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(favGr);
if (entry.getValue().size() == favGr.points.size()) {
markersHelper.addOrEnableGroup(markersGr);
} else {
for (FavouritePoint fp : entry.getValue()) {
points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
}
markersHelper.addMapMarkers(points, names, markersGr);
points.clear();
names.clear();
}
}
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}
use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.
the class OsmandAidlApi method removeMapMarker.
boolean removeMapMarker(AMapMarker marker) {
if (marker != null) {
LatLon latLon = new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude());
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
for (MapMarker m : mapMarkers) {
if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
markersHelper.moveMapMarkerToHistory(m);
refreshMap();
return true;
}
}
return false;
} else {
return false;
}
}
use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.
the class OsmandAidlApi method addMapMarker.
boolean addMapMarker(AMapMarker marker) {
if (marker != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, marker.getName() != null ? marker.getName() : "");
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
markersHelper.addMapMarker(new LatLon(marker.getLatLon().getLatitude(), marker.getLatLon().getLongitude()), pd);
refreshMap();
return true;
} else {
return false;
}
}
use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.
the class OsmandAidlApi method updateMapMarker.
boolean updateMapMarker(AMapMarker markerPrev, AMapMarker markerNew) {
if (markerPrev != null && markerNew != null) {
LatLon latLon = new LatLon(markerPrev.getLatLon().getLatitude(), markerPrev.getLatLon().getLongitude());
LatLon latLonNew = new LatLon(markerNew.getLatLon().getLatitude(), markerNew.getLatLon().getLongitude());
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
for (MapMarker m : mapMarkers) {
if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
marker.id = m.id;
marker.creationDate = m.creationDate;
marker.visitedDate = m.visitedDate;
markersHelper.moveMapMarker(marker, latLonNew);
refreshMap();
return true;
}
}
return false;
} else {
return false;
}
}
use of net.osmand.plus.MapMarkersHelper in project Osmand by osmandapp.
the class MapMarkersLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom());
OsmandSettings settings = map.getMyApplication().getSettings();
if (tileBox.getZoom() < 3) {
return;
}
int displayedWidgets = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get();
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
for (MapMarker marker : markersHelper.getMapMarkers()) {
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker) && !isInMotion(marker) && !isSynced(marker)) {
Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
int marginX = bmp.getWidth() / 6;
int marginY = bmp.getHeight();
int locationX = tileBox.getPixXFromLonNoRot(marker.getLongitude());
int locationY = tileBox.getPixYFromLatNoRot(marker.getLatitude());
canvas.rotate(-tileBox.getRotate(), locationX, locationY);
canvas.drawBitmap(bmp, locationX - marginX, locationY - marginY, bitmapPaint);
canvas.rotate(tileBox.getRotate(), locationX, locationY);
}
}
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
LatLon loc = tileBox.getCenterLatLon();
int i = 0;
for (MapMarker marker : markersHelper.getMapMarkers()) {
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
canvas.save();
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), marker.getLatitude(), marker.getLongitude(), calculations);
float bearing = calculations[1] - 90;
float radiusBearing = DIST_TO_SHOW * tileBox.getDensity();
final QuadPoint cp = tileBox.getCenterPixelPoint();
canvas.rotate(bearing, cp.x, cp.y);
canvas.translate(-24 * tileBox.getDensity() + radiusBearing, -22 * tileBox.getDensity());
canvas.drawBitmap(arrowShadow, cp.x, cp.y, bitmapPaint);
canvas.drawBitmap(arrowToDestination, cp.x, cp.y, getMarkerDestPaint(marker.colorIndex));
canvas.drawBitmap(arrowLight, cp.x, cp.y, bitmapPaint);
canvas.restore();
}
i++;
if (i > displayedWidgets - 1) {
break;
}
}
}
if (contextMenuLayer.getMoveableObject() instanceof MapMarker) {
MapMarker objectInMotion = (MapMarker) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
Bitmap bitmap = getMapMarkerBitmap(objectInMotion.colorIndex);
int marginX = bitmap.getWidth() / 6;
int marginY = bitmap.getHeight();
float locationX = pf.x;
float locationY = pf.y;
canvas.rotate(-tileBox.getRotate(), locationX, locationY);
canvas.drawBitmap(bitmap, locationX - marginX, locationY - marginY, bitmapPaint);
}
}
Aggregations