Skip to content

Commit

Permalink
Fix declaration type on setCameraOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudleclerc committed Apr 17, 2021
1 parent 5366c55 commit c54365d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions samples/AzureMapsControl.Sample/Pages/Controls.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@using AzureMapsControl.Components.Map
<AzureMap Id="map"
CameraOptions="new CameraOptions { Type = AzureMapsControl.Components.Map.CameraType.Fly }"
Controls="new Components.Controls.Control[]
{
new Components.Controls.ZoomControl(new Components.Controls.ZoomControlOptions { Style = AzureMapsControl.Components.Controls.ControlStyle.Dark }, AzureMapsControl.Components.Controls.ControlPosition.TopLeft),
Expand Down
2 changes: 1 addition & 1 deletion samples/AzureMapsControl.Sample/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@using AzureMapsControl.Components.Map
<AzureMap Id="map"
CameraOptions="new CameraOptions { Center= new AzureMapsControl.Components.Atlas.Position(11.581990, 48.143534), Zoom= 8.5, MinZoom = 3, MaxZoom = 12.5 }"
CameraOptions="new CameraOptions { Type = AzureMapsControl.Components.Map.CameraType.Fly, Center= new AzureMapsControl.Components.Atlas.Position(11.581990, 48.143534), Zoom= 8.5, MinZoom = 3, MaxZoom = 12.5 }"
StyleOptions="StyleOptions"/>

@code {
Expand Down
29 changes: 29 additions & 0 deletions samples/AzureMapsControl.Sample/Pages/WithCameraOptions.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@page "/WithCameraOptions"

@using AzureMapsControl.Components.Map
<AzureMap Id="map"
CameraOptions="new CameraOptions { Center= new AzureMapsControl.Components.Atlas.Position(11.581990, 48.143534), Zoom= 8.5, MinZoom = 3, MaxZoom = 12.5 }"
StyleOptions="StyleOptions"
EventActivationFlags="MapEventActivationFlags
.None()
.Enable(MapEventType.Click)"
OnClick="OnMapClick" />

@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;
});
}
}
6 changes: 3 additions & 3 deletions src/AzureMapsControl.Components/typescript/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c54365d

Please sign in to comment.