diff --git a/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx b/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx index 4a0ac2b88..f62484ceb 100644 --- a/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +++ b/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx @@ -101,6 +101,11 @@ const OsmProtocolSourceDemo = () => { mapHook.map?.jumpTo({ center: [2.651811, 39.571309], zoom: 16.5 }); }, [mapHook.map]); + // useSource({sourceId: "test", source: { + // type: 'geojson', + // data: `osm://osm/palma.osm?completeFeature=true&allFeatures=false&renderTagged=false&excludeWay=false&suppressWay=false`, + // } }) + return ( <> { }, }} options={{ - source: { + source: + { type: 'geojson', data: `osm://osm/palma.osm?completeFeature=true&allFeatures=false&renderTagged=false&excludeWay=false&suppressWay=false`, }, }} labelProp="name" - labelOptions={{ + labelOptions={{ paint: { 'text-color': '#ff0000', }, @@ -505,4 +511,4 @@ DefaultPaintOverrides.args = { geojson: sample_geojson_1, type: 'fill' }; export const CatalogueDemo = catalogueTemplate.bind({}); CatalogueDemo.parameters = {}; -CatalogueDemo.args = {}; \ No newline at end of file +CatalogueDemo.args = {}; diff --git a/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx b/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx index 46f2b2523..a5cf40345 100644 --- a/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +++ b/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx @@ -144,9 +144,11 @@ const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => { useLayer({ mapId: props.mapId, layerId: layerId.current, - options: { - source: 'source-' + layerId.current, - ...props.options, + options: { + ...(typeof props?.options?.source !== 'undefined' && + typeof props?.options?.source === 'string' + ? {source: props.options.source} + : {source: 'source-' + layerId.current}), paint: { ...(props.paint || getDefaultPaintPropsByType(layerType, props.defaultPaintOverrides)), ...props?.options?.paint, @@ -168,7 +170,10 @@ const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => { useLayer({ mapId: props.mapId, options: { - source: props.labelProp ? 'source-' + layerId.current : undefined, + ...(typeof props?.options?.source !== 'undefined' && + typeof props?.options?.source === 'string' + ? {source: props.options.source} + : {source: 'source-' + layerId.current}), id: labelLayerId, type: 'symbol', maxzoom: 24,