Skip to content

Commit

Permalink
fix: GeoJSON with resource appearance on reearth/core (#432)
Browse files Browse the repository at this point in the history
fix: geojson on resource
  • Loading branch information
keiya01 committed Feb 7, 2023
1 parent 0d4e0bf commit 464d67f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/engines/Cesium/Feature/Resource/index.tsx
Expand Up @@ -6,7 +6,7 @@ import {
import { useCallback, useMemo } from "react";
import { KmlDataSource, CzmlDataSource, GeoJsonDataSource, useCesium } from "resium";

import { evalFeature } from "@reearth/core/mantle";
import { DataType, evalFeature } from "@reearth/core/mantle";

import type { ResourceAppearance, AppearanceTypes } from "../../..";
import { extractSimpleLayerData, type FeatureComponentConfig, type FeatureProps } from "../utils";
Expand All @@ -33,13 +33,18 @@ const delegatingAppearance: Record<keyof typeof comps, (keyof AppearanceTypes)[]
czml: ["marker", "polyline", "polygon"],
};

const DataTypeListAllowsOnlyProperty: DataType[] = ["geojson"];

export default function Resource({ isVisible, property, layer }: Props) {
const { clampToGround } = property ?? {};
const [type, url] = useMemo((): [ResourceAppearance["type"], string | undefined] => {
const data = extractSimpleLayerData(layer);
const type = property?.type;
const url = property?.url;
return [type ?? (data?.type as ResourceAppearance["type"]), url ?? data?.url];
return [
type ?? (data?.type as ResourceAppearance["type"]),
url ?? (data && !DataTypeListAllowsOnlyProperty.includes(data.type) ? data?.url : undefined),
];
}, [property, layer]);
const { viewer } = useCesium();

Expand Down

0 comments on commit 464d67f

Please sign in to comment.