add OSM edit/note icons
This commit is contained in:
parent
cfa98dcba7
commit
914fb88869
2 changed files with 38 additions and 3 deletions
|
@ -4,6 +4,6 @@
|
|||
android:viewportWidth="36"
|
||||
android:viewportHeight="36">
|
||||
<path
|
||||
android:pathData="M5,2L31,2A3,3 0,0 1,34 5L34,31A3,3 0,0 5,31 34L5,34A3,3 0,0 1,2 31L2,5A3,3 0,0 1,5 2z"
|
||||
android:fillColor="#727272" />
|
||||
android:pathData="m8,2h20c2,0 3,1 3,3v16c0,2 -1,3 -3,3h-5l-5,4 -5,-4H8C6,24 5,23 5,21V5C5,3 6,2 8,2Z"
|
||||
android:fillColor="#727272"/>
|
||||
</vector>
|
||||
|
|
|
@ -12,16 +12,19 @@ import androidx.core.content.ContextCompat;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Entity;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.PointImageDrawable;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
|
||||
ContextMenuLayer.IMoveObjectProvider {
|
||||
|
@ -78,7 +81,7 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
|
||||
private void drawPoint(Canvas canvas, OsmPoint o, float x, float y) {
|
||||
float textScale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
|
||||
int iconId = R.drawable.mx_special_information;
|
||||
int iconId = getIconId(o);
|
||||
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(activity,
|
||||
ContextCompat.getColor(activity, R.color.created_poi_icon_color), true,
|
||||
iconId);
|
||||
|
@ -86,6 +89,38 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC
|
|||
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
|
||||
}
|
||||
|
||||
|
||||
public int getIconId(OsmPoint osmPoint) {
|
||||
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
|
||||
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
|
||||
int iconResId = 0;
|
||||
String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG);
|
||||
if (poiTranslation != null && activity != null) {
|
||||
Map<String, PoiType> poiTypeMap = activity.getMyApplication().getPoiTypes().getAllTranslatedNames(false);
|
||||
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
|
||||
if (poiType != null) {
|
||||
String id = null;
|
||||
if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) {
|
||||
id = poiType.getIconKeyName();
|
||||
} else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) {
|
||||
id = poiType.getOsmTag() + "_" + poiType.getOsmValue();
|
||||
}
|
||||
if (id != null) {
|
||||
iconResId = RenderingIcons.getBigIconResourceId(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iconResId == 0) {
|
||||
iconResId = R.drawable.ic_action_info_dark;
|
||||
}
|
||||
return iconResId;
|
||||
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
|
||||
return R.drawable.ic_action_bug_dark;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue