Releases: arnaudleclerc/AzureMapsControl.Components
1.5.0
Adding support of Popup templates (#36)
You can now apply a PopupTemplate
to a popup. Please refer to the documentation for more details.
1.4.0
Features
DataSource
now supports adding features using a JSON string or aJSONDocument
. The expected format is a JSON representation of aFeatureCollection
.DataSource
can be disposed usingDisposeAsync
. No operation is possible on the datasource once it has been disposed. Trying to use a disposed datasource will throw aComponentDisposedException
.- The current options of the datasource can be retrieved from the
azure-maps
instance of the datasource usingGetOptionsAsync
. - The shapes of the datasource can be retrieved using
GetShapesAsync
. This works fine with a small dataset of data but might lead to issues with a larger one. - When creating a datasource, you can now pass some
EventActivationFlags
to react to events on the datasource. Supported events aredataadded
,dataremoved
,sourceadded
,sourceremoved
, anddatasourceupdated
.
1.3.0
Features
On the Map
, 4 new methods allow you to retrieve the current map options : GetCameraOptionsAsync
, GetStyleOptionsAsync
, GetTrafficOptionsAsync
, GetUserInteractionOptionsAsync
. This can for example be used to retrieve the current zoom level of the map.
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;
});
}
Bugfix
- The
Zoom
property onMoveAlongPathAnimationOptions
,RoutePathAnimationOptions
,SetCoordinatesAnimationOptions
,SnakeLineAnimationOptions
,OverviewMapControlOptions
,CameraOptions
are now of typedouble?
(previouslyint?
). The same applies toZoomDelta
onZoomControlOptions
.
1.2.0
Features
#37 - Setting properties on the canvas and on the canvas container of the map.
The following methods have been added on the map class :
SetCanvasStylePropertyAsync
andSetCanvasStylePropertiesAsync
to add properties on the canvas of the map.SetCanvasContainerStylePropertyAsync
andSetCanvasContainerStylePropertiesAsync
to add properties on the container of the canvas of the map.
1.1.0
Features
- #39 - Adding a
GeolocationControl
which allows you to use the current location of the browser on your application. More information on the docs.
Changes
ComponentNotAddedToMapException
Some components need to be added to the map before being able to call their methods. Prior to the 1.1.0
, calling the methods of a component interacting with the atlas library before adding it to the map would raise a NullReferenceException
. The following methods will now raise a ComponentNotAddedToMapException
indicating that the object needs to be added to the map first :
GeolocationControl
:GetLastKnownPositionAsync
,DisposeAsync
,SetOptionsAsync
.OverviewMapControl
:UpdateAsync
,SetOptionsAsync
.DataSource
:AddAsync
,RemoveAsync
,ImportDataFromUrlAsync
,ClearAsync
.HtmlMarker
:TogglePopupAsync
.Popup
:OpenAsync
,CloseAsync
,RemoveAsync
,UpdateAsync
,SetOptionsAsync
.
ValueTask instead of Task
The previously named methods now returns a ValueTask
instead of a Task
.
API deprecation
The UpdateAsync
methods on OverviewMapControl
and Popup
are deprecated and will be removed in a future major version. They will still be supported on the future v1 versions. On both of those classes, you can use SetOptionsAsync
instead.
1.0.0
This version mostly contains improvements on the organization of the source code and on the workflows to build the library.
A couple of noticeable API changes have been introduced.
API Changes
- The
AddAsync
methods on aDataSource
now expects an instance ofShape<TGeometry>
orFeature<TGeometry>
instead of the geometry itself. This was necessary to have a stable codebase and be able to serialize and deserialize shapes and feature more easilly. - The events on the map and on the layers now contains the Shapes and the Features attached to the event. Each object also contains its coordinates.
0.17.1
Adding Features to datasource
Two new signatures for the AddAsync
method on DataSource:
Task AddAsync(IEnumerable<Feature> features)
Task AddAsync(params Feature[] features)
The calls to AddAsync now support adding geometries which are wrapped into shapes, but also adding features containing a geometry. The added features are accessible via the Features
property of the datasource.
@page "/SymbolLayerWithFeatures"
@using AzureMapsControl.Components.Map
<AzureMap Id="map"
CameraOptions="new CameraOptions { Zoom = 16, Center = new Components.Atlas.Position(-122.13284, 47.63699) }"
EventActivationFlags="MapEventActivationFlags
.None()
.Enable(MapEventType.Ready)"
OnReady="OnMapReady" />
i
@code {
public async Task OnMapReady(MapEventArgs eventArgs)
{
var datasourceId = "datasourceId";
var datasource = new AzureMapsControl.Components.Data.DataSource(datasourceId);
await eventArgs.Map.AddSourceAsync(datasource);
var feature = new AzureMapsControl.Components.Atlas.Feature<AzureMapsControl.Components.Atlas.Point>(new AzureMapsControl.Components.Atlas.Point(
new AzureMapsControl.Components.Atlas.Position(-122.13284, 47.63699)
), new Dictionary<string, object> {
{ "title", "Cafeteria" },
{ "subtitle", "Building 40"}
});
await datasource.AddAsync(feature);
var textFieldExpressionJsonString = "[\"format\", [\"get\", \"title\"], {\"text-font\": [\"literal\", [\"StandardFont-Bold\"]], \"font-scale\": 1.25}, \"\\n\", {}, [\"get\", \"subtitle\"], {\"font-scale\": 0.75}]";
var layer = new AzureMapsControl.Components.Layers.SymbolLayer {
Options = new Components.Layers.SymbolLayerOptions {
Source = datasourceId,
TextOptions = new Components.Layers.TextOptions {
TextField = new Components.Atlas.ExpressionOrString(
System.Text.Json.JsonDocument.Parse(textFieldExpressionJsonString)
)
}
}
};
await eventArgs.Map.AddLayerAsync(layer);
}
}
Removing a feature is possible by calling the RemoveAsync method of the datasource, just like for the geometries. Some new API are available to remove only geometries, only features or both of them.
Adding Popup to HtmlMarkers
New features
- #33 - Add Popup to HtmlMarker.Options
Description
You can now define a Popup on the options of an HtmlMarker. The Popup can then be toggled by calling TogglePopupAsync
on the HtmlMarker.
The Popup can also be used from the Map just like the other popups. A call to TogglePopupAsync
is necessary before using it from the instance of Map
, or you can also set the OpenOnAdd
property to true
to display it automatically.
@page "/HtmlMarkerPopup"
@using AzureMapsControl.Components.Map
<AzureMap Id="map"
EventActivationFlags="MapEventActivationFlags
.None()
.Enable(MapEventType.Ready)"
OnReady="OnMapReady" />
@code {
public async Task OnMapReady(MapEventArgs events)
{
var marker = new AzureMapsControl.Components.Markers.HtmlMarker(
new Components.Markers.HtmlMarkerOptions
{
Position = new Components.Atlas.Position(0, 0),
Draggable = true,
Popup = new Components.Popups.HtmlMarkerPopup(new Components.Popups.PopupOptions
{
Content = "<div style='padding:10px'>Hello World</div>",
PixelOffset = new Components.Atlas.Pixel(0, -30)
})
})
{
EventActivationFlags = Components.Markers.HtmlMarkerEventActivationFlags.None().Enable(Components.Markers.HtmlMarkerEventType.Click)
};
await events.Map.AddHtmlMarkersAsync(marker);
marker.OnClick += async (eventArgs) =>
{
await marker.TogglePopupAsync();
};
}
}
Animations
This version brings animations into the library.
The animations
are not part of the atlas
library, so you need to include the js file directly into your application via a script tag. It can be found on the GitHub repository of the animations.
To create an animation, you can inject an instance of IAnimationService
inside your razor views or services. The following animations can be created via this service :
DropAsync
: Adds an offset array property to point shapes and animates its y value to simulate dropping.DropMarkersAsync
: Adds an offset to HtmlMarkers to animate its y value to simulate dropping.GroupAnimationAsync
: Group multiple animationsFlowingDashedLineAsync
: Animates the dash-array of a line layer to make it appear to flow.MoveAlongPath
: Animates a Point shape or a marker along a path.MoveAlongRouteAsync
: Animates a Point shape along a route path.MorphAsync
: Animates the morphing of a shape from one geometry type or set of coordinates to another.SetCoordinatesAsync
: Animates the update of coordinates on a shape.SnakelineAsync
: Animates the path of a LineString.
Each of those methods gives back an Animation which you can further control using its PlayAsync
, PauseAsync
, ResetAsync
, SeekAsync
, StopAsync
and DisposeAsync
methods. Not all the animations exposes those methods.
Note that if you try to use an animation which has already been disposed, the library will raise an AnimationAlreadyDisposedException
.