From 686ee3fa3255ebb3ed975cc02b36e48f322202e2 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Fri, 6 Nov 2026 09:49:23 -0800 Subject: [PATCH] Show URL-loaded ImageIcon and ground image in the sample The Marker page gets a fifth row with ImageIcon(imageUrl:). The Ground Image page gets a "Load from URL" button (also --groundImageUrl at launch); tapping the image switches back to the bundled images, which clears imageUrl. Points ios-sdk-core at the URL-loading change. --- ios-sdk-core | 2 +- .../pages/groundimage/GroundImageMapPage.swift | 3 +++ .../groundimage/GroundImagePageViewModel.swift | 13 +++++++++++++ .../marker/icons/MarkerBasicMapComponent.swift | 13 +++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ios-sdk-core b/ios-sdk-core index a899663..b03d6b9 160000 --- a/ios-sdk-core +++ b/ios-sdk-core @@ -1 +1 @@ -Subproject commit a899663f7662b64b5333271c84e71d9b5f390a31 +Subproject commit b03d6b92a4d9097b2cc296b9f638229facfa493d diff --git a/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImageMapPage.swift b/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImageMapPage.swift index dedb7c7..029a898 100644 --- a/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImageMapPage.swift +++ b/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImageMapPage.swift @@ -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) diff --git a/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImagePageViewModel.swift b/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImagePageViewModel.swift index f3421ed..009515f 100644 --- a/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImagePageViewModel.swift +++ b/samples/MapConductorSampleApp/Sources/pages/groundimage/GroundImagePageViewModel.swift @@ -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 diff --git a/samples/MapConductorSampleApp/Sources/pages/marker/icons/MarkerBasicMapComponent.swift b/samples/MapConductorSampleApp/Sources/pages/marker/icons/MarkerBasicMapComponent.swift index a80d941..691ec7f 100644 --- a/samples/MapConductorSampleApp/Sources/pages/marker/icons/MarkerBasicMapComponent.swift +++ b/samples/MapConductorSampleApp/Sources/pages/marker/icons/MarkerBasicMapComponent.swift @@ -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