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);
}
}
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());
}
}
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);
}
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);
}
}
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;
}
Aggregations