use of net.osmand.plus.mapmarkers.MapMarker in project OsmAnd by osmandapp.
the class MapContextMenu method getMapMarker.
@Nullable
private MapMarker getMapMarker() {
MenuController menuController = getMenuController();
Object correspondingObj = menuController != null ? menuController.getCorrespondingMapObject() : null;
if (correspondingObj instanceof MapMarker) {
return (MapMarker) correspondingObj;
}
Object object = getObject();
if (object instanceof MapMarker) {
return (MapMarker) object;
}
return null;
}
use of net.osmand.plus.mapmarkers.MapMarker in project OsmAnd by osmandapp.
the class QuickSearchListItem method getIcon.
@Nullable
public static Drawable getIcon(OsmandApplication app, SearchResult searchResult) {
if (searchResult == null || searchResult.objectType == null) {
return null;
}
int iconId = -1;
switch(searchResult.objectType) {
case CITY:
return getIcon(app, R.drawable.ic_action_building2);
case VILLAGE:
return getIcon(app, R.drawable.ic_action_village);
case POSTCODE:
case STREET:
return getIcon(app, R.drawable.ic_action_street_name);
case HOUSE:
return getIcon(app, R.drawable.ic_action_building);
case STREET_INTERSECTION:
return getIcon(app, R.drawable.ic_action_intersection);
case POI_TYPE:
if (searchResult.object instanceof AbstractPoiType) {
String iconName = PoiUIFilter.getPoiTypeIconName((AbstractPoiType) searchResult.object);
if (!Algorithms.isEmpty(iconName)) {
iconId = RenderingIcons.getBigIconResourceId(iconName);
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
CustomSearchPoiFilter searchPoiFilter = (CustomSearchPoiFilter) searchResult.object;
PoiUIFilter filter = app.getPoiFilters().getFilterById(searchPoiFilter.getFilterId());
if (filter != null) {
iconId = getCustomFilterIconRes(filter);
}
}
if (iconId > 0) {
return getIcon(app, iconId);
} else {
return getIcon(app, R.drawable.ic_action_search_dark);
}
case POI:
Amenity amenity = (Amenity) searchResult.object;
String id = getAmenityIconName(amenity);
Drawable icon = null;
if (id != null) {
iconId = RenderingIcons.getBigIconResourceId(id);
if (iconId > 0) {
icon = getIcon(app, iconId);
}
}
if (icon == null) {
return getIcon(app, R.drawable.ic_action_search_dark);
} else {
return icon;
}
case GPX_TRACK:
return getIcon(app, R.drawable.ic_action_polygom_dark);
case LOCATION:
return getIcon(app, R.drawable.ic_action_world_globe);
case FAVORITE:
FavouritePoint fav = (FavouritePoint) searchResult.object;
int color = app.getFavoritesHelper().getColorWithCategory(fav, ContextCompat.getColor(app, R.color.color_favorite));
return PointImageDrawable.getFromFavorite(app, color, false, fav);
case FAVORITE_GROUP:
FavoriteGroup group = (FavoriteGroup) searchResult.object;
color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor();
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_favorite, color | 0xff000000);
case REGION:
return getIcon(app, R.drawable.ic_world_globe_dark);
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) searchResult.object;
iconId = getHistoryIconId(app, entry);
try {
return getIcon(app, iconId);
} catch (Exception e) {
return getIcon(app, SearchHistoryFragment.getItemIcon(entry.getName()));
}
case WPT:
WptPt wpt = (WptPt) searchResult.object;
return PointImageDrawable.getFromWpt(app, wpt.getColor(), false, wpt);
case MAP_MARKER:
MapMarker marker = (MapMarker) searchResult.object;
if (!marker.history) {
return MapMarkerDialogHelper.getMapMarkerIcon(app, marker.colorIndex);
} else {
return getIcon(app, R.drawable.ic_action_flag);
}
case ROUTE:
return getIcon(app, R.drawable.ic_action_previous_route);
case UNKNOWN_NAME_FILTER:
break;
}
return null;
}
use of net.osmand.plus.mapmarkers.MapMarker in project OsmAnd by osmandapp.
the class FavouritesLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof FavouritePoint) {
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
MapMarker mapMarker = mapMarkersHelper.getMapMarker(objectInMotion);
float textScale = getTextScale();
drawBigPoint(canvas, objectInMotion, pf.x, pf.y, mapMarker, textScale);
}
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class SearchScreen method reloadHistoryInternal.
private void reloadHistoryInternal() {
if (!destroyed) {
OsmandApplication app = getApp();
try {
List<SearchResult> recentResults = new ArrayList<>();
// Home / work
/* Disable since points exists at favorites screen
FavouritesDbHelper favorites = app.getFavorites();
FavouritePoint homePoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.HOME);
FavouritePoint workPoint = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.WORK);
if (homePoint != null) {
SearchResult result = new SearchResult();
result.location = new LatLon(homePoint.getLatitude(), homePoint.getLongitude());
result.objectType = ObjectType.FAVORITE;
result.object = homePoint;
result.localeName = homePoint.getAddress();
recentResults.add(result);
}
if (workPoint != null) {
SearchResult result = new SearchResult();
result.location = new LatLon(workPoint.getLatitude(), workPoint.getLongitude());
result.objectType = ObjectType.FAVORITE;
result.object = workPoint;
result.localeName = workPoint.getAddress();
recentResults.add(result);
}
*/
// Previous route card
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
TargetPoint startPoint = targetPointsHelper.getPointToStartBackup();
boolean myLocation = false;
if (startPoint == null) {
myLocation = true;
startPoint = targetPointsHelper.getMyLocationToStart();
}
TargetPoint destinationPoint = targetPointsHelper.getPointToNavigateBackup();
if (startPoint != null && destinationPoint != null) {
StringBuilder startText = new StringBuilder(myLocation ? app.getText(R.string.my_location) : "");
String startDescr = getPointName(startPoint);
if (!Algorithms.isEmpty(startDescr)) {
if (startText.length() > 0) {
startText.append(" — ");
}
startText.append(startDescr);
}
String destDescr = getPointName(destinationPoint);
SearchResult result = new SearchResult();
result.location = new LatLon(destinationPoint.getLatitude(), destinationPoint.getLongitude());
result.objectType = ObjectType.ROUTE;
result.object = destinationPoint;
result.localeName = destDescr;
result.relatedObject = startPoint;
result.localeRelatedObjectName = startText.toString();
recentResults.add(result);
}
// Map markers
List<MapMarker> mapMarkers = app.getMapMarkersHelper().getMapMarkers();
int mapMarkersCount = 0;
for (MapMarker marker : mapMarkers) {
SearchResult result = new SearchResult();
result.location = new LatLon(marker.getLatitude(), marker.getLongitude());
result.objectType = ObjectType.MAP_MARKER;
result.object = marker;
result.localeName = marker.getName(app);
recentResults.add(result);
mapMarkersCount++;
if (mapMarkersCount >= MAP_MARKERS_LIMIT) {
break;
}
}
// History
SearchResultCollection res = getSearchUICore().shallowSearch(SearchHistoryAPI.class, "", null, false, false);
if (res != null) {
recentResults.addAll(res.getCurrentSearchResults());
}
this.recentResults = recentResults;
if (!searchHelper.isSearching() && Algorithms.isEmpty(searchHelper.getSearchQuery())) {
showRecents();
invalidate();
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
app.showToastMessage(e.getMessage());
}
}
}
use of net.osmand.plus.mapmarkers.MapMarker in project Osmand by osmandapp.
the class MapMarkerEditorFragment method save.
private void save(boolean needDismiss) {
String name = nameEdit.getText().toString().trim();
if (Algorithms.isBlank(name)) {
nameEdit.setError(getString(R.string.wrong_input));
} else {
OsmandApplication app = getMyApplication();
if (editor != null && app != null) {
MapMarker marker = editor.getMarker();
marker.setOriginalPointDescription(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, name));
app.getMapMarkersHelper().updateMapMarker(marker, true);
}
if (needDismiss) {
dismiss(true);
}
}
}
Aggregations