Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ios-sdk-core
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ struct GroundImageMapPage: View {
.font(.subheadline)
.foregroundColor(.secondary)

Button("Load from URL") { viewModel.loadFromUrl() }
.font(.subheadline)

VStack(alignment: .leading, spacing: 6) {
Text("opacity: \(String(format: "%.2f", viewModel.opacity))")
.font(.subheadline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,21 @@ final class GroundImagePageViewModel: ObservableObject {

updateLabelsAndBounds()
groundImageState.opacity = opacity
if ProcessInfo.processInfo.arguments.contains("--groundImageUrl") {
loadFromUrl()
}
}

/// 画像を URL から読み込む(読み終えるまでは今の画像のまま)。地表画像をタップすると
/// 同梱の画像に戻る(`image` を入れると `imageUrl` は外れる)。
func loadFromUrl() {
groundImageState.imageUrl = GroundImagePageViewModel.remoteImageUrl
}

static let remoteImageUrl = URL(
string: "https://raw.githubusercontent.com/MapConductor/react-sdk/develop/examples/basic/public/university_of_eswatini.png"
)!

func setOpacity(_ value: Double) {
let resolved = min(max(value, 0.0), 1.0)
opacity = resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,22 @@ struct MarkerBasicMapComponent: View {
)))
}

// Row 5: ImageIcon loaded from a URL (transparent until the image arrives)
markers.append(Marker(state: MarkerState(
position: GeoPoint(latitude: 0.002, longitude: 0.004),
id: "ii_url",
extra: "ImageIcon(\n imageUrl: URL(string: \"https://…/tokyo.png\")!\n)",
icon: ImageIcon(imageUrl: MarkerBasicMapComponent.remoteIconUrl),
onClick: onMarkerClick
)))

return markers
}

private static let remoteIconUrl = URL(
string: "https://raw.githubusercontent.com/MapConductor/react-sdk/develop/examples/basic/public/city-icons/tokyo.png"
)!

private var onMarkerClick: OnMarkerEventHandler {
{ [self] state in
selectedSnippet = state.extra as? String
Expand Down