Search in sources :

Example 1 with MapInfoLayer

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();
}
Also used : MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer)

Example 2 with MapInfoLayer

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);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) ITileSource(net.osmand.map.ITileSource) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 3 with MapInfoLayer

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;
            }
        });
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) MenuItem(android.view.MenuItem) ContextMenuItem(net.osmand.plus.ContextMenuItem) ImageView(android.widget.ImageView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ObservableListView(com.github.ksoichiro.android.observablescrollview.ObservableListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AbsListView(android.widget.AbsListView) ScrollView(android.widget.ScrollView) MapWidgetRegistry(net.osmand.plus.views.mapwidgets.MapWidgetRegistry) ImageButton(android.widget.ImageButton) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) TextView(android.widget.TextView) DashboardSettingsDialogFragment(net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment) ImageView(android.widget.ImageView) Toolbar(androidx.appcompat.widget.Toolbar)

Example 4 with MapInfoLayer

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();
}
Also used : MapControlsLayer(net.osmand.plus.views.layers.MapControlsLayer) PointLocationLayer(net.osmand.plus.views.layers.PointLocationLayer) MapMarkersLayer(net.osmand.plus.views.layers.MapMarkersLayer) POIMapLayer(net.osmand.plus.views.layers.POIMapLayer) MeasurementToolLayer(net.osmand.plus.measurementtool.MeasurementToolLayer) ImpassableRoadsLayer(net.osmand.plus.views.layers.ImpassableRoadsLayer) ContextMenuLayer(net.osmand.plus.views.layers.ContextMenuLayer) MapVectorLayer(net.osmand.plus.views.layers.MapVectorLayer) RouteLayer(net.osmand.plus.views.layers.RouteLayer) MapQuickActionLayer(net.osmand.plus.views.layers.MapQuickActionLayer) GPXLayer(net.osmand.plus.views.layers.GPXLayer) FavouritesLayer(net.osmand.plus.views.layers.FavouritesLayer) PointNavigationLayer(net.osmand.plus.views.layers.PointNavigationLayer) MapTextLayer(net.osmand.plus.views.layers.MapTextLayer) DownloadedRegionsLayer(net.osmand.plus.views.layers.DownloadedRegionsLayer) RadiusRulerControlLayer(net.osmand.plus.views.layers.RadiusRulerControlLayer) DistanceRulerControlLayer(net.osmand.plus.views.layers.DistanceRulerControlLayer) MapTileLayer(net.osmand.plus.views.layers.MapTileLayer) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) PreviewRouteLineLayer(net.osmand.plus.views.layers.PreviewRouteLineLayer) TransportStopsLayer(net.osmand.plus.views.layers.TransportStopsLayer)

Example 5 with MapInfoLayer

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);
}
Also used : Context(android.content.Context) TextInfoWidget(net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget) WeakReference(java.lang.ref.WeakReference) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapInfoLayer (net.osmand.plus.views.layers.MapInfoLayer)24 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)6 View (android.view.View)4 MapActivity (net.osmand.plus.activities.MapActivity)4 TextInfoWidget (net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget)4 ContextMenuItem (net.osmand.plus.ContextMenuItem)3 MapControlsLayer (net.osmand.plus.views.layers.MapControlsLayer)3 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 WeakReference (java.lang.ref.WeakReference)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 MapLayers (net.osmand.plus.views.MapLayers)2 SuppressLint (android.annotation.SuppressLint)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 MenuItem (android.view.MenuItem)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1