Persilsoft.GeolocationMap.Blazor
1.0.6
See the version list below for details.
dotnet add package Persilsoft.GeolocationMap.Blazor --version 1.0.6
NuGet\Install-Package Persilsoft.GeolocationMap.Blazor -Version 1.0.6
<PackageReference Include="Persilsoft.GeolocationMap.Blazor" Version="1.0.6" />
paket add Persilsoft.GeolocationMap.Blazor --version 1.0.6
#r "nuget: Persilsoft.GeolocationMap.Blazor, 1.0.6"
// Install Persilsoft.GeolocationMap.Blazor as a Cake Addin #addin nuget:?package=Persilsoft.GeolocationMap.Blazor&version=1.0.6 // Install Persilsoft.GeolocationMap.Blazor as a Cake Tool #tool nuget:?package=Persilsoft.GeolocationMap.Blazor&version=1.0.6
Persilsoft.GeolocationMap.Blazor
This package integrates the retrieval of geographical coordinates and addresses provided by the Persilsoft.Nominatim.Geolocation package, with the mapping capabilities offered by the Persilsoft.Leaflet.Blazor package.
Example
First, you need to register the following service groups in the dependency container.
using ServiceCollectionExtensions;
builder.Services.AddGeolocationService();
builder.Services.AddNominatimGeocoderService();
builder.Services.AddLeafletServices();
Now, you can use it:
@page "/show-position"
@using Persilsoft.Nominatim.Geolocation.Blazor.Geocoding
<div class="map-container">
<GeolocationMap OnSetPosition="OnSetPosition"
OnSetPositionError="OnSetPositionError" />
</div>
<div class="mt-2">
@(new MarkupString(errorMessage))
</div>
@code {
private string errorMessage;
private void OnSetPosition(GeocodingAddress address)
{
errorMessage = $"Coordinates: ({address.Latitude}, {address.Longitude})<br/>" +
$"Address: {address.DisplayAddress} <br/>" +
$"Country: {address.CountryCode} <br/>" +
$"Department: {address.Department} <br/>" +
$"Province: {address.Province} <br/>" +
$"District: {address.District} <br/>" +
$"Reference: {address.Reference} <br/>";
}
private void OnSetPositionError(string message)
{
errorMessage = message;
}
}
If you want to set your own icon for the marker, you can use the ImageUrl parameter.
<GeolocationMap OnSetPosition="OnSetPosition"
OnSetPositionError="OnSetPositionError"
ImageUrl="images/my-home.png"/>
Note that it's recommended for your icon to have a size of 32x32 pixels.*
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (= 8.0.10)
- Persilsoft.Leaflet.Blazor (= 1.0.9)
- Persilsoft.Localizer (= 1.0.7)
- Persilsoft.Nominatim.Geolocation.Blazor (= 1.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.