-
Notifications
You must be signed in to change notification settings - Fork 9
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(arcgis): convert link to rest format #338
Changes from 2 commits
1608de8
8802f6d
161fd8f
96fc0a6
41c24bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
import { useState } from "react"; | ||
import styled, { css } from "styled-components"; | ||
import { load } from "@loaders.gl/core"; | ||
import { forEach, load } from "@loaders.gl/core"; | ||
|
||
import { | ||
LayerExample, | ||
|
@@ -197,11 +197,33 @@ | |
|
||
useClickOutside([warningNode], () => setShowExistedError(false)); | ||
|
||
const convertUrlToRestFormat = (url: string): string => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
let urlRest = "https://www.arcgis.com/sharing/rest/content/items/"; | ||
const urlObject = new URL(url); | ||
|
||
let param: string | null = null; | ||
for (const paramName of ["id", "webscene", "layers"]) { | ||
param = urlObject.searchParams.get(paramName); | ||
if (param) { | ||
break; | ||
} | ||
} | ||
if (param) { | ||
urlRest += param + "/data"; | ||
} else { | ||
// The url cannot be converted. Use it "as is". | ||
return url; | ||
} | ||
return urlRest; | ||
}; | ||
|
||
const handleInsertLayer = (layer: { | ||
name: string; | ||
url: string; | ||
token?: string; | ||
}) => { | ||
layer.url = convertUrlToRestFormat(layer.url); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it really work for layers? We were about doing it for scenes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||
|
||
const existedLayer = layers.some( | ||
(exisLayer) => exisLayer.url.trim() === layer.url.trim() | ||
); | ||
|
@@ -253,6 +275,8 @@ | |
url: string; | ||
token?: string; | ||
}) => { | ||
scene.url = convertUrlToRestFormat(scene.url); | ||
|
||
const existedScene = layers.some( | ||
(exisLayer) => exisLayer.url.trim() === scene.url.trim() | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.