Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): add VisualizerContext in NLS for beta #591

Merged
merged 2 commits into from Jul 26, 2023
Merged

Conversation

keiya01
Copy link
Member

@keiya01 keiya01 commented Jul 26, 2023

Overview

I added VisualizerContext API to access to the API of the Visualizer.

You can access like this.

const visualizer = useVisualizer();
visualizer.current?.engine.flyTo({
  lat: 35.683252649879606,
  lng: 139.75262379931652,
  height: 5000,
});
visualizer.current?.layers.add({
  type: "simple",
  data: {
    type: "geojson",
    value: {
      // GeoJSON
      type: "Feature",
      geometry: {
        coordinates: [139.75262379931652, 35.683252649879606, 1000],
        type: "Point",
      },
    },
  },
  marker: {
    imageColor: "blue",
  },
});

What I've done

  • Added VisualizerContext API
  • Added onMount props to Visualizer

What I haven't done

How I tested

  1. Go to storybook on preview
  2. Move to ?path/story/beta-lib-core-visualizer--api
  3. Set the Cesium token to meta props on the bottom bar in storybook
{
"cesiumIonAccessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhYzVkMTc1ZS00NTRhLTRjY2QtYTQwZS01YmU2Mjg1ODAwN2YiLCJpZCI6MjU5LCJpYXQiOjE2ODgzOTgwMjl9.MZC_HUBRd0y5HJeB-F5QSpT-fEgTM6mI5gMaSND9FHc"
}
  1. Reload the page, then camera is moved and one marker is added.

Which point I want you to review particularly

Memo

@keiya01 keiya01 requested review from isoppp and airslice July 26, 2023 07:48
@keiya01 keiya01 self-assigned this Jul 26, 2023
@keiya01 keiya01 requested a review from KaWaite as a code owner July 26, 2023 07:48
@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 3b961cf
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/64c0d9fc92470600085063d0
😎 Deploy Preview https://deploy-preview-591--reearth-web.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@keiya01 keiya01 changed the title feat: add VisualizerContext in NLS for beta feat(web): add VisualizerContext in NLS for beta Jul 26, 2023
@github-actions github-actions bot added the web label Jul 26, 2023
@github-actions github-actions bot requested a review from nina992 July 26, 2023 07:48
@keiya01
Copy link
Member Author

keiya01 commented Jul 26, 2023

You can use this API like this storybook page.

const Content: FC<{ ready?: boolean }> = ({ ready }) => {
const visualizer = useVisualizer();
useEffect(() => {
if (!ready) return;
visualizer.current?.engine.flyTo({
lat: 35.683252649879606,
lng: 139.75262379931652,
height: 5000,
});
visualizer.current?.layers.add({
type: "simple",
data: {
type: "geojson",
value: {
// GeoJSON
type: "Feature",
geometry: {
coordinates: [139.75262379931652, 35.683252649879606, 1000],
type: "Point",
},
},
},
marker: {
imageColor: "blue",
},
});
}, [visualizer, ready]);
return null;
};
const VisualizerWrapper: FC<ComponentProps<typeof Component>> = props => {
const [ready, setReady] = useState(false);
return (
<Component {...props} onMount={() => setReady(true)}>
<Content ready={ready} />
</Component>
);
};

@keiya01 keiya01 removed the request for review from isoppp July 26, 2023 07:53
@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Merging #591 (3b961cf) into main (ad4ae6d) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #591      +/-   ##
==========================================
- Coverage   28.28%   28.27%   -0.02%     
==========================================
  Files        1420     1421       +1     
  Lines      152717   152797      +80     
  Branches     3643     3644       +1     
==========================================
  Hits        43200    43200              
- Misses     108365   108445      +80     
  Partials     1152     1152              
Flag Coverage Δ
web 26.15% <0.00%> (-0.02%) ⬇️
web-beta 26.15% <0.00%> (-0.02%) ⬇️
web-classic 26.15% <0.00%> (-0.02%) ⬇️
web-utils 26.15% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...eta/features/Editor/Visualizer/CanvasArea/hooks.ts 0.00% <0.00%> (ø)
...ta/features/Editor/Visualizer/CanvasArea/index.tsx 0.00% <0.00%> (ø)
web/src/beta/lib/core/Map/types/index.ts 0.00% <0.00%> (ø)
web/src/beta/lib/core/Visualizer/context.tsx 0.00% <0.00%> (ø)
web/src/beta/lib/core/Visualizer/hooks.ts 0.00% <0.00%> (ø)
web/src/beta/lib/core/Visualizer/index.tsx 0.00% <0.00%> (ø)
web/src/beta/lib/core/engines/Cesium/hooks.ts 0.00% <0.00%> (ø)
web/src/beta/lib/core/engines/Cesium/index.tsx 0.00% <0.00%> (ø)

@keiya01 keiya01 enabled auto-merge (squash) July 26, 2023 08:32
@keiya01 keiya01 merged commit 39811d4 into main Jul 26, 2023
17 checks passed
@keiya01 keiya01 deleted the feat/core-context branch July 26, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants