Skip to content

Commit

Permalink
Basic link to google earth
Browse files Browse the repository at this point in the history
  • Loading branch information
davenquinn committed Oct 2, 2023
1 parent a43e907 commit 86796f2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/globe-dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ function getStartingPosition(): MapPosition {

const _CesiumView = memo(CesiumView);

function GoogleEarthLink({ position }) {
const base = "https://earth.google.com/web/";
const { camera, target } = position;
const { altitude, pitch, bearing, azimuth } = camera;
let url = base;
if (target == null) {
url += `@${camera.lat},${camera.lng},${
altitude * 100
}d,${bearing}h,${pitch}t`;
} else {
const { lat, lng, distance } = target;
url += `@${lat},${lng},${distance}d,${bearing}h,${pitch}t`;
}

return h("a", { href: url, target: "_blank" }, "Open in Google Earth");
}

function App({ accessToken }) {
const initialPosition = useRef<MapPosition>(getStartingPosition());

Expand Down Expand Up @@ -118,6 +135,7 @@ function App({ accessToken }) {
setShown: setShowMapbox,
}),
h(Link, { href: mapURL }, "Switch to map"),
h(GoogleEarthLink, { position }, "Open in Google Earth"),
]),
]),
h("div.map-container", [
Expand Down

0 comments on commit 86796f2

Please sign in to comment.