use of net.osmand.plus.views.layers.AidlMapLayer 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.AidlMapLayer 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);
}
}
Aggregations