use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.
the class MapillaryPlugin method registerWidget.
private void registerWidget(@NonNull MapActivity activity) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
mapillaryControl = createMonitoringControl(activity);
mapillaryWidgetRegInfo = layer.registerSideWidget(mapillaryControl, R.drawable.ic_action_mapillary, R.string.mapillary, "mapillary", false, 19);
layer.recreateControls();
}
use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.
the class MapillaryPlugin method updateMapLayers.
private void updateMapLayers(@NonNull Context context, @Nullable MapActivity mapActivity, boolean force) {
if (vectorLayer == null) {
createLayers(context);
}
OsmandApplication app = (OsmandApplication) context.getApplicationContext();
OsmandSettings settings = app.getSettings();
OsmandMapTileView mapView = app.getOsmandMap().getMapView();
if (isActive()) {
ITileSource vectorSource = null;
if (SHOW_MAPILLARY.get() || force) {
vectorSource = settings.getTileSourceByName(TileSourceManager.getMapillaryVectorSource().getName(), false);
}
updateLayer(mapView, vectorSource, vectorLayer, 0.62f);
if (mapillaryControl == null && mapActivity != null) {
registerWidget(mapActivity);
}
} else {
mapView.removeLayer(vectorLayer);
vectorLayer.setMap(null);
if (mapActivity != null) {
MapInfoLayer mapInfoLayer = mapActivity.getMapLayers().getMapInfoLayer();
if (mapillaryControl != null && mapInfoLayer != null) {
mapInfoLayer.removeSideWidget(mapillaryControl);
mapillaryControl = null;
mapInfoLayer.recreateControls();
}
}
mapillaryControl = null;
}
app.getOsmandMap().getMapLayers().updateMapSource(mapView, null);
}
use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.
the class DashboardOnMap method updateToolbarActions.
private void updateToolbarActions() {
TextView tv = dashboardView.findViewById(R.id.toolbar_text);
tv.setText("");
if (visibleType == DashboardType.CONFIGURE_MAP) {
tv.setText(R.string.configure_map);
} else if (visibleType == DashboardType.CONFIGURE_SCREEN) {
tv.setText(R.string.layer_map_appearance);
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
tv.setText(R.string.shared_string_settings);
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
tv.setText(R.string.map_underlay);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
tv.setText(R.string.map_overlay);
} else if (visibleType == DashboardType.MAPILLARY) {
tv.setText(R.string.street_level_imagery);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
tv.setText(R.string.srtm_plugin_name);
} else if (visibleType == DashboardType.OSM_NOTES) {
tv.setText(R.string.osm_notes);
} else if (visibleType == DashboardType.TERRAIN) {
tv.setText(R.string.shared_string_terrain);
} else if (visibleType == DashboardType.WIKIPEDIA) {
tv.setText(R.string.shared_string_wikipedia);
} else if (visibleType == DashboardType.CYCLE_ROUTES) {
tv.setText(R.string.rendering_attr_showCycleRoutes_name);
} else if (visibleType == DashboardType.HIKING_ROUTES) {
tv.setText(R.string.rendering_attr_hikingRoutesOSMC_name);
} else if (visibleType == DashboardType.TRAVEL_ROUTES) {
tv.setText(R.string.travel_routes);
}
ImageView edit = dashboardView.findViewById(R.id.toolbar_edit);
edit.setVisibility(View.GONE);
ImageView sort = dashboardView.findViewById(R.id.toolbar_sort);
sort.setVisibility(View.GONE);
ImageView ok = dashboardView.findViewById(R.id.toolbar_ok);
ok.setVisibility(View.GONE);
ImageView flat = dashboardView.findViewById(R.id.toolbar_flat);
flat.setVisibility(View.GONE);
ImageView settingsButton = dashboardView.findViewById(R.id.toolbar_settings);
settingsButton.setVisibility(View.GONE);
ImageView lst = dashboardView.findViewById(R.id.toolbar_list);
lst.setVisibility(View.GONE);
ImageButton back = dashboardView.findViewById(R.id.toolbar_back);
Drawable icBack = getMyApplication().getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(mapActivity));
back.setImageDrawable(icBack);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
backPressed();
}
});
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new DashboardSettingsDialogFragment().show(mapActivity.getSupportFragmentManager(), "dashboard_settings");
}
});
lst.setVisibility(View.VISIBLE);
lst.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideDashboard(false);
mapActivity.openDrawer();
}
});
}
toolbar.getMenu().clear();
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
toolbar.inflateMenu(R.menu.refresh_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.action_refresh) {
MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry();
registry.resetToDefault();
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity));
}
return false;
}
});
}
}
use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.
the class MapLayers method createLayers.
public void createLayers(@NonNull OsmandMapTileView mapView) {
// first create to make accessible
mapTextLayer = new MapTextLayer(app);
// 5.95 all labels
mapView.addLayer(mapTextLayer, 5.95f);
// 8. context menu layer
contextMenuLayer = new ContextMenuLayer(app);
mapView.addLayer(contextMenuLayer, 8);
// mapView.addLayer(underlayLayer, -0.5f);
mapTileLayer = new MapTileLayer(app, true);
mapView.addLayer(mapTileLayer, 0.05f);
mapView.setMainLayer(mapTileLayer);
// 0.5 layer
mapVectorLayer = new MapVectorLayer(app);
mapView.addLayer(mapVectorLayer, 0.0f);
downloadedRegionsLayer = new DownloadedRegionsLayer(app);
mapView.addLayer(downloadedRegionsLayer, 0.5f);
// 0.9 gpx layer
gpxLayer = new GPXLayer(app);
mapView.addLayer(gpxLayer, 0.9f);
// 1. route layer
routeLayer = new RouteLayer(app);
mapView.addLayer(routeLayer, 1);
// 1.5 preview route line layer
previewRouteLineLayer = new PreviewRouteLineLayer(app);
mapView.addLayer(previewRouteLineLayer, 1.5f);
// 2. osm bugs layer
// 3. poi layer
poiMapLayer = new POIMapLayer(app);
mapView.addLayer(poiMapLayer, 3);
// 4. favorites layer
mFavouritesLayer = new FavouritesLayer(app);
mapView.addLayer(mFavouritesLayer, 4);
// 4.6 measurement tool layer
measurementToolLayer = new MeasurementToolLayer(app);
mapView.addLayer(measurementToolLayer, 4.6f);
// 5. transport layer
transportStopsLayer = new TransportStopsLayer(app);
mapView.addLayer(transportStopsLayer, 5);
// 5.95 all text labels
// 6. point location layer
locationLayer = new PointLocationLayer(app);
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(app);
mapView.addLayer(navigationLayer, 7);
// 7.3 map markers layer
mapMarkersLayer = new MapMarkersLayer(app);
mapView.addLayer(mapMarkersLayer, 7.3f);
// 7.5 Impassible roads
impassableRoadsLayer = new ImpassableRoadsLayer(app);
mapView.addLayer(impassableRoadsLayer, 7.5f);
// 7.8 radius ruler control layer
radiusRulerControlLayer = new RadiusRulerControlLayer(app);
mapView.addLayer(radiusRulerControlLayer, 7.8f);
// 7.9 ruler by tap control layer
distanceRulerControlLayer = new DistanceRulerControlLayer(app);
mapView.addLayer(distanceRulerControlLayer, 7.9f);
// 8. context menu layer
// 9. map info layer
mapInfoLayer = new MapInfoLayer(app, routeLayer);
mapView.addLayer(mapInfoLayer, 9);
// 11. route info layer
mapControlsLayer = new MapControlsLayer(app);
mapView.addLayer(mapControlsLayer, 11);
// 12. quick actions layer
mapQuickActionLayer = new MapQuickActionLayer(app);
mapView.addLayer(mapQuickActionLayer, 12);
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
transparencyListener = change -> app.runInUIThread(() -> {
mapTileLayer.setAlpha(change);
mapVectorLayer.setAlpha(change);
mapView.refreshMap();
});
app.getSettings().MAP_TRANSPARENCY.addListener(transparencyListener);
createAdditionalLayers();
}
use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.
the class OsmandAidlApi method registerRemoveMapWidgetReceiver.
private void registerRemoveMapWidgetReceiver(@NonNull MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver removeMapWidgetReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
String packName = intent.getStringExtra(AIDL_PACKAGE_NAME);
if (mapActivity != null && widgetId != null && packName != null) {
ConnectedApp connectedApp = connectedApps.get(packName);
if (connectedApp != null) {
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
TextInfoWidget widgetControl = connectedApp.getWidgetControls().get(widgetId);
if (layer != null && widgetControl != null) {
layer.removeSideWidget(widgetControl);
connectedApp.getWidgetControls().remove(widgetId);
layer.recreateControls();
}
}
}
}
};
registerReceiver(removeMapWidgetReceiver, mapActivity, AIDL_REMOVE_MAP_WIDGET);
}
Aggregations