From c54365d451143c1d3a6c19efc5dc86bb92b93452 Mon Sep 17 00:00:00 2001 From: Arnaud Leclerc Date: Sat, 17 Apr 2021 21:22:04 +0200 Subject: [PATCH] Fix declaration type on setCameraOptions --- .../Pages/Controls.razor | 1 + .../AzureMapsControl.Sample/Pages/Index.razor | 2 +- .../Pages/WithCameraOptions.razor | 29 +++++++++++++++++++ .../typescript/core/core.ts | 6 ++-- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 samples/AzureMapsControl.Sample/Pages/WithCameraOptions.razor diff --git a/samples/AzureMapsControl.Sample/Pages/Controls.razor b/samples/AzureMapsControl.Sample/Pages/Controls.razor index e49b385..6308c09 100644 --- a/samples/AzureMapsControl.Sample/Pages/Controls.razor +++ b/samples/AzureMapsControl.Sample/Pages/Controls.razor @@ -2,6 +2,7 @@ @using AzureMapsControl.Components.Map @code { diff --git a/samples/AzureMapsControl.Sample/Pages/WithCameraOptions.razor b/samples/AzureMapsControl.Sample/Pages/WithCameraOptions.razor new file mode 100644 index 0000000..fabb0f4 --- /dev/null +++ b/samples/AzureMapsControl.Sample/Pages/WithCameraOptions.razor @@ -0,0 +1,29 @@ +@page "/WithCameraOptions" + +@using AzureMapsControl.Components.Map + + +@code { + public StyleOptions StyleOptions = new StyleOptions + { + Style = MapStyle.GrayscaleDark, + ShowLogo = false, + ShowFeedbackLink = false + }; + + public async Task OnMapClick(MapMouseEventArgs eventArgs) + { + var options = await eventArgs.Map.GetCameraOptionsAsync(); + await eventArgs.Map.SetCameraOptionsAsync(cameraOptions => { + cameraOptions.Type = CameraType.Fly; + cameraOptions.Duration = 1000; + cameraOptions.Zoom = options.Zoom + 1; + }); + } +} \ No newline at end of file diff --git a/src/AzureMapsControl.Components/typescript/core/core.ts b/src/AzureMapsControl.Components/typescript/core/core.ts index 0494919..9b3d281 100644 --- a/src/AzureMapsControl.Components/typescript/core/core.ts +++ b/src/AzureMapsControl.Components/typescript/core/core.ts @@ -357,15 +357,15 @@ export class Core { } } - public static setCameraOptions(cameraOptions: azmaps.CameraOptions & azmaps.CameraBoundsOptions): void { - const options: azmaps.CameraOptions & azmaps.CameraBoundsOptions = { + public static setCameraOptions(cameraOptions: (azmaps.CameraOptions | azmaps.CameraBoundsOptions) & azmaps.AnimationOptions): void { + const options: (azmaps.CameraOptions | azmaps.CameraBoundsOptions) & azmaps.AnimationOptions = { bearing: cameraOptions.bearing, centerOffset: cameraOptions.centerOffset, duration: cameraOptions.duration, maxZoom: cameraOptions.maxZoom, minZoom: cameraOptions.minZoom, pitch: cameraOptions.pitch, - type: cameraOptions.cameraType + type: cameraOptions.type }; if (cameraOptions.bounds) {