Search in sources :

Example 1 with OsmandMapLayer

use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.

the class MapLayers method setMapActivity.

public void setMapActivity(@Nullable MapActivity mapActivity) {
    OsmandMapTileView mapView = app.getOsmandMap().getMapView();
    for (OsmandMapLayer layer : mapView.getLayers()) {
        MapActivity layerMapActivity = layer.getMapActivity();
        if (mapActivity != null && layerMapActivity != null) {
            layer.setMapActivity(null);
        }
        layer.setMapActivity(mapActivity);
    }
}
Also used : OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) MapActivity(net.osmand.plus.activities.MapActivity)

Example 2 with OsmandMapLayer

use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.

the class OsmandMapTileView method drawOverMap.

@SuppressLint("WrongCall")
public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
    if (mapRenderer == null) {
        fillCanvas(canvas, drawSettings);
    }
    final QuadPoint c = tileBox.getCenterPixelPoint();
    synchronized (this) {
        if (bufferBitmap != null && !bufferBitmap.isRecycled() && mapRenderer == null) {
            canvas.save();
            canvas.rotate(tileBox.getRotate(), c.x, c.y);
            drawBasemap(canvas);
            canvas.restore();
        }
    }
    if (onDrawMapListener != null) {
        onDrawMapListener.onDrawOverMap();
    }
    for (int i = 0; i < layers.size(); i++) {
        try {
            OsmandMapLayer layer = layers.get(i);
            canvas.save();
            // rotate if needed
            if (!layer.drawInScreenPixels()) {
                canvas.rotate(tileBox.getRotate(), c.x, c.y);
            }
            if (mapRenderer != null) {
                layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
            }
            layer.onDraw(canvas, tileBox, drawSettings);
            canvas.restore();
        } catch (IndexOutOfBoundsException e) {
        // skip it
        }
    }
    if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
        drawMapPosition(canvas, c.x, c.y);
    } else if (multiTouchSupport != null && multiTouchSupport.isInZoomMode()) {
        drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y);
    } else if (doubleTapScaleDetector != null && doubleTapScaleDetector.isInZoomMode()) {
        drawMapPosition(canvas, doubleTapScaleDetector.getCenterX(), doubleTapScaleDetector.getCenterY());
    }
}
Also used : QuadPoint(net.osmand.data.QuadPoint) OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 3 with OsmandMapLayer

use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.

the class OsmandAidlApi method registerAddMapLayerReceiver.

private void registerAddMapLayerReceiver(@NonNull MapActivity mapActivity) {
    final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
    BroadcastReceiver addMapLayerReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            MapActivity mapActivity = mapActivityRef.get();
            String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
            String packName = intent.getStringExtra(AIDL_PACKAGE_NAME);
            if (mapActivity != null && layerId != null && packName != null) {
                ConnectedApp connectedApp = connectedApps.get(packName);
                if (connectedApp != null) {
                    AidlMapLayerWrapper layer = connectedApp.getLayers().get(layerId);
                    if (layer != null) {
                        OsmandMapLayer mapLayer = connectedApp.getMapLayers().get(layerId);
                        if (mapLayer != null) {
                            mapActivity.getMapView().removeLayer(mapLayer);
                        }
                        mapLayer = new AidlMapLayer(mapActivity, layer, connectedApp.getPack());
                        mapActivity.getMapView().addLayer(mapLayer, layer.getZOrder());
                        connectedApp.getMapLayers().put(layerId, mapLayer);
                    }
                }
            }
        }
    };
    registerReceiver(addMapLayerReceiver, mapActivity, AIDL_ADD_MAP_LAYER);
}
Also used : Context(android.content.Context) WeakReference(java.lang.ref.WeakReference) OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) AidlMapLayer(net.osmand.plus.views.layers.AidlMapLayer) MapActivity(net.osmand.plus.activities.MapActivity)

Example 4 with OsmandMapLayer

use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.

the class ConnectedApp method registerMapLayers.

void registerMapLayers(@NonNull Context context) {
    OsmandApplication app = (OsmandApplication) context.getApplicationContext();
    OsmandMapTileView mapView = app.getOsmandMap().getMapView();
    for (AidlMapLayerWrapper layer : layers.values()) {
        OsmandMapLayer mapLayer = mapLayers.get(layer.getId());
        if (mapLayer != null) {
            mapView.removeLayer(mapLayer);
        }
        mapLayer = new AidlMapLayer(context, layer, pack);
        mapView.addLayer(mapLayer, layer.getZOrder());
        mapLayers.put(layer.getId(), mapLayer);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AidlMapLayer(net.osmand.plus.views.layers.AidlMapLayer)

Example 5 with OsmandMapLayer

use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.

the class ContextMenuLayer method disableSingleTap.

public boolean disableSingleTap() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null || mapActivity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible || MapRouteInfoMenu.followTrackVisible) {
        return true;
    }
    boolean res = false;
    for (OsmandMapLayer lt : view.getLayers()) {
        if (lt instanceof IContextMenuProvider) {
            if (((IContextMenuProvider) lt).disableSingleTap()) {
                res = true;
                break;
            }
        }
    }
    return res;
}
Also used : OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

OsmandMapLayer (net.osmand.plus.views.layers.base.OsmandMapLayer)13 MapActivity (net.osmand.plus.activities.MapActivity)6 Paint (android.graphics.Paint)4 LatLon (net.osmand.data.LatLon)4 SuppressLint (android.annotation.SuppressLint)2 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 WeakReference (java.lang.ref.WeakReference)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 TreeMap (java.util.TreeMap)2 FavouritePoint (net.osmand.data.FavouritePoint)2 QuadPoint (net.osmand.data.QuadPoint)2 AidlMapLayer (net.osmand.plus.views.layers.AidlMapLayer)2 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Pair (android.util.Pair)1 NonNull (androidx.annotation.NonNull)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1