)}
diff --git a/public/components/map_page/map_page.tsx b/public/components/map_page/map_page.tsx
index 0151d9a0..f6726825 100644
--- a/public/components/map_page/map_page.tsx
+++ b/public/components/map_page/map_page.tsx
@@ -37,7 +37,7 @@ interface MapComponentProps {
mapConfig: ConfigSchema;
mapIdFromSavedObject: string;
timeRange?: TimeRange;
- inDashboardMode: boolean;
+ isReadOnlyMode: boolean;
refreshConfig?: RefreshInterval;
filters?: Filter[];
query?: Query;
@@ -46,7 +46,7 @@ export const MapComponent = ({
mapIdFromSavedObject,
mapConfig,
timeRange,
- inDashboardMode,
+ isReadOnlyMode,
refreshConfig,
filters,
query,
@@ -61,6 +61,7 @@ export const MapComponent = ({
const [layersIndexPatterns, setLayersIndexPatterns] = useState
([]);
const maplibreRef = useRef(null);
const [mapState, setMapState] = useState(getInitialMapState());
+ const [isUpdatingLayerRender, setIsUpdatingLayerRender] = useState(true);
useEffect(() => {
if (mapIdFromSavedObject) {
@@ -91,10 +92,10 @@ export const MapComponent = ({
return (
- {inDashboardMode ? null : (
+ {isReadOnlyMode ? null : (
)}
@@ -113,11 +115,13 @@ export const MapComponent = ({
maplibreRef={maplibreRef}
mapState={mapState}
mapConfig={mapConfig}
- inDashboardMode={inDashboardMode}
+ isReadOnlyMode={isReadOnlyMode}
timeRange={timeRange}
refreshConfig={refreshConfig}
filters={filters}
query={query}
+ isUpdatingLayerRender={isUpdatingLayerRender}
+ setIsUpdatingLayerRender={setIsUpdatingLayerRender}
/>
);
@@ -125,7 +129,5 @@ export const MapComponent = ({
export const MapPage = ({ mapConfig }: MapPageProps) => {
const { id: mapId } = useParams<{ id: string }>();
- return (
-
- );
+ return ;
};
diff --git a/public/components/map_top_nav/top_nav_menu.tsx b/public/components/map_top_nav/top_nav_menu.tsx
index b5b9a184..7d688b51 100644
--- a/public/components/map_top_nav/top_nav_menu.tsx
+++ b/public/components/map_top_nav/top_nav_menu.tsx
@@ -24,21 +24,23 @@ interface MapTopNavMenuProps {
maplibreRef: any;
mapState: MapState;
setMapState: (mapState: MapState) => void;
- inDashboardMode: boolean;
+ isReadOnlyMode: boolean;
timeRange?: TimeRange;
originatingApp?: string;
+ setIsUpdatingLayerRender: (isUpdatingLayerRender: boolean) => void;
}
export const MapTopNavMenu = ({
mapIdFromUrl,
savedMapObject,
- inDashboardMode,
+ isReadOnlyMode,
timeRange,
layers,
layersIndexPatterns,
maplibreRef,
mapState,
setMapState,
+ setIsUpdatingLayerRender,
}: MapTopNavMenuProps) => {
const { services } = useOpenSearchDashboards();
const {
@@ -96,6 +98,7 @@ export const MapTopNavMenu = ({
};
const handleQuerySubmit = ({ query, dateRange }: { query?: Query; dateRange: TimeRange }) => {
+ setIsUpdatingLayerRender(true);
if (query) {
setMapState({ ...mapState, query });
}
@@ -105,7 +108,7 @@ export const MapTopNavMenu = ({
};
useEffect(() => {
- if (!inDashboardMode) {
+ if (!isReadOnlyMode) {
setDateFrom(mapState.timeRange.from);
setDateTo(mapState.timeRange.to);
} else {
@@ -144,9 +147,9 @@ export const MapTopNavMenu = ({
config={config}
setMenuMountPoint={setHeaderActionMenu}
indexPatterns={layersIndexPatterns || []}
- showSearchBar={!inDashboardMode}
+ showSearchBar={!isReadOnlyMode}
showFilterBar={false}
- showDatePicker={!inDashboardMode}
+ showDatePicker={!isReadOnlyMode}
showQueryBar={true}
showSaveQuery={true}
showQueryInput={true}
diff --git a/public/embeddable/map_component.tsx b/public/embeddable/map_component.tsx
index a2fb58f4..afb420f2 100644
--- a/public/embeddable/map_component.tsx
+++ b/public/embeddable/map_component.tsx
@@ -41,7 +41,7 @@ export function MapEmbeddableComponentInner({ embeddable, input }: Props) {
mapConfig={embeddable.getMapConfig()}
mapIdFromSavedObject={input.savedObjectId}
timeRange={timeRange}
- inDashboardMode={true}
+ isReadOnlyMode={true}
refreshConfig={refreshConfig}
filters={filters}
query={query}
diff --git a/public/model/layerRenderController.ts b/public/model/layerRenderController.ts
index cf160535..e4b276a2 100644
--- a/public/model/layerRenderController.ts
+++ b/public/model/layerRenderController.ts
@@ -4,7 +4,7 @@
*/
import { Map as Maplibre } from 'maplibre-gl';
-import { DocumentLayerSpecification, MapLayerSpecification } from './mapLayerType';
+import { MapLayerSpecification } from './mapLayerType';
import { DASHBOARDS_MAPS_LAYER_TYPE } from '../../common';
import {
buildOpenSearchQuery,
@@ -92,7 +92,7 @@ export const prepareDataLayerSource = (
};
export const handleDataLayerRender = (
- mapLayer: DocumentLayerSpecification,
+ mapLayer: MapLayerSpecification,
mapState: MapState,
services: MapServices,
maplibreRef: MaplibreRef,
@@ -101,6 +101,9 @@ export const handleDataLayerRender = (
filtersFromDashboard?: Filter[],
query?: Query
) => {
+ if (mapLayer.type !== DASHBOARDS_MAPS_LAYER_TYPE.DOCUMENTS) {
+ return;
+ }
// filters are passed from dashboard filters and geo bounding box filters
const filters: Filter[] = [];
filters.push(...(filtersFromDashboard ? filtersFromDashboard : []));
diff --git a/public/model/layersFunctions.ts b/public/model/layersFunctions.ts
index 71625459..52448abc 100644
--- a/public/model/layersFunctions.ts
+++ b/public/model/layersFunctions.ts
@@ -61,3 +61,24 @@ export const referenceLayerTypeLookup = {
[DASHBOARDS_MAPS_LAYER_TYPE.CUSTOM_MAP]: true,
[DASHBOARDS_MAPS_LAYER_TYPE.DOCUMENTS]: false,
};
+
+export const getDataLayers = (layers: MapLayerSpecification[]) => {
+ return layers.filter((layer) => !referenceLayerTypeLookup[layer.type]);
+};
+
+export const getReferenceLayers = (layers: MapLayerSpecification[]) => {
+ return layers.filter((layer) => referenceLayerTypeLookup[layer.type]);
+};
+
+// Get layer id from layers that is above the selected layer
+export const getMapBeforeLayerId = (
+ layers: MapLayerSpecification[],
+ selectedLayerId: string
+): string | undefined => {
+ const selectedLayerIndex = layers.findIndex((layer) => layer.id === selectedLayerId);
+ const beforeLayers = layers.slice(selectedLayerIndex + 1);
+ if (beforeLayers.length === 0) {
+ return undefined;
+ }
+ return beforeLayers[0]?.id;
+};