diff --git a/packages/client/.storybook/main.js b/packages/client/.storybook/main.js
index 32ce43328..57d1f6f45 100644
--- a/packages/client/.storybook/main.js
+++ b/packages/client/.storybook/main.js
@@ -22,6 +22,16 @@ module.exports = {
],
include: path.resolve(__dirname, "../"),
});
+ config.module.rules.push({
+ test: /\.cjs/,
+ include: /node_modules/,
+ type: "javascript/auto",
+ });
+ config.module.rules.push({
+ test: /\.mjs/,
+ include: /node_modules/,
+ type: "javascript/auto",
+ });
return config;
},
};
diff --git a/packages/client/src/admin/data/arcgis/ArcGISCartLegend.tsx b/packages/client/src/admin/data/arcgis/ArcGISCartLegend.tsx
index 5614c72c3..8ece541a3 100644
--- a/packages/client/src/admin/data/arcgis/ArcGISCartLegend.tsx
+++ b/packages/client/src/admin/data/arcgis/ArcGISCartLegend.tsx
@@ -15,7 +15,7 @@ import Spinner from "../../../components/Spinner";
import { Layer, Map } from "mapbox-gl";
import {
SeaSketchGlLayer,
- compileLegendFromGLStyleLayers2,
+ compileLegendFromGLStyleLayers,
} from "../../../dataLayers/legends/compileLegend";
import { memo } from "react";
import SimpleSymbol from "../../../dataLayers/legends/SimpleSymbol";
@@ -304,7 +304,7 @@ const SimpleLegendIconFromStyle = memo(
}) {
let data: LegendForGLLayers | undefined;
try {
- data = compileLegendFromGLStyleLayers2(props.style.layers, "vector");
+ data = compileLegendFromGLStyleLayers(props.style.layers, "vector");
} catch (e) {
// Do nothing
}
diff --git a/packages/client/src/dataLayers/Legend.tsx b/packages/client/src/dataLayers/Legend.tsx
index 76d8f80d2..0f613052c 100644
--- a/packages/client/src/dataLayers/Legend.tsx
+++ b/packages/client/src/dataLayers/Legend.tsx
@@ -79,10 +79,12 @@ export default function Legend({
maxHeight = maxHeight || undefined;
return (
@@ -224,30 +226,6 @@ function PanelFactory({ panel, map }: { panel: GLLegendPanel; map?: Map }) {
);
}
-function LegendImage({
- item,
- className,
-}: {
- item: LegendSymbolItem;
- className?: string;
-}) {
- return (
- 1 ? window.devicePixelRatio / 1.5 : 1)
- }
- height={
- (item.imageHeight || 20) /
- (window.devicePixelRatio > 1 ? window.devicePixelRatio / 1.5 : 1)
- }
- />
- );
-}
-
function Toggle({
visible,
onChange,
diff --git a/packages/client/src/dataLayers/MapContextManager.ts b/packages/client/src/dataLayers/MapContextManager.ts
index 42f5dd942..93c48adba 100644
--- a/packages/client/src/dataLayers/MapContextManager.ts
+++ b/packages/client/src/dataLayers/MapContextManager.ts
@@ -48,7 +48,7 @@ import LRU from "lru-cache";
import debounce from "lodash.debounce";
import { currentSidebarState } from "../projects/ProjectAppSidebar";
import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
-import { compileLegendFromGLStyleLayers2 } from "./legends/compileLegend";
+import { compileLegendFromGLStyleLayers } from "./legends/compileLegend";
import { LegendItem } from "./Legend";
import { EventEmitter } from "eventemitter3";
import MeasureControl, {
@@ -2460,10 +2460,14 @@ class MapContextManager extends EventEmitter {
if (sourceType) {
try {
console.time("legend2");
- const legend2 = compileLegendFromGLStyleLayers2(
+ const legend2 = compileLegendFromGLStyleLayers(
layer.mapboxGlStyles,
sourceType
);
+ console.log("items");
+ console.log(layer.mapboxGlStyles);
+ console.log("legend");
+ console.log(legend2);
console.timeEnd("legend2");
if (legend2) {
diff --git a/packages/client/src/dataLayers/legends/FillSymbol.tsx b/packages/client/src/dataLayers/legends/FillSymbol.tsx
index aef5d70b1..82753a6a4 100644
--- a/packages/client/src/dataLayers/legends/FillSymbol.tsx
+++ b/packages/client/src/dataLayers/legends/FillSymbol.tsx
@@ -11,11 +11,11 @@ export default function FillSymbol({
map,
}: {
data: GLLegendFillSymbol;
- map: Map;
+ map?: Map;
}) {
const [imageData, setImageData] = useState();
useEffect(() => {
- if (!imageData && data.patternImageId) {
+ if (map && !imageData && data.patternImageId) {
const resolvedImage = getImage(data.patternImageId, map);
if (resolvedImage) {
setImageData(resolvedImage);
diff --git a/packages/client/src/dataLayers/legends/LegendListPanel.tsx b/packages/client/src/dataLayers/legends/LegendListPanel.tsx
index 9a50c4b11..5e591b8d4 100644
--- a/packages/client/src/dataLayers/legends/LegendListPanel.tsx
+++ b/packages/client/src/dataLayers/legends/LegendListPanel.tsx
@@ -22,7 +22,7 @@ export default function LegendListPanel({
className={`flex items-center space-x-2 max-w-full`}
>
- {map && item.symbol ? (
+ {item.symbol ? (
) : null}
diff --git a/packages/client/src/dataLayers/legends/LegendSimpleSymbolPanel.tsx b/packages/client/src/dataLayers/legends/LegendSimpleSymbolPanel.tsx
index 508bcf583..e2f80ce45 100644
--- a/packages/client/src/dataLayers/legends/LegendSimpleSymbolPanel.tsx
+++ b/packages/client/src/dataLayers/legends/LegendSimpleSymbolPanel.tsx
@@ -1,8 +1,5 @@
import SimpleSymbol from "./SimpleSymbol";
-import {
- GLLegendListPanel,
- GLLegendSimpleSymbolPanel,
-} from "./LegendDataModel";
+import { GLLegendSimpleSymbolPanel } from "./LegendDataModel";
import { Map } from "mapbox-gl";
export default function LegendSimpleSymbolPanel({
@@ -26,7 +23,7 @@ export default function LegendSimpleSymbolPanel({
className={`flex items-center space-x-2 max-w-full`}
>
- {map && item.symbol ? (
+ {item.symbol ? (
) : null}
diff --git a/packages/client/src/dataLayers/legends/SimpleSymbol.tsx b/packages/client/src/dataLayers/legends/SimpleSymbol.tsx
index d36d1f581..6d34e3b00 100644
--- a/packages/client/src/dataLayers/legends/SimpleSymbol.tsx
+++ b/packages/client/src/dataLayers/legends/SimpleSymbol.tsx
@@ -8,7 +8,7 @@ import CircleSymbol from "./CircleSymbol";
export default function SimpleSymbol(props: {
data: GLLegendSymbol;
- map: Map;
+ map?: Map;
}) {
switch (props.data.type) {
case "line":
@@ -16,7 +16,9 @@ export default function SimpleSymbol(props: {
case "fill":
return ;
case "marker":
- return ;
+ return props.map ? (
+
+ ) : null;
case "text":
return (