Persilsoft.GeolocationMap.Blazor 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Persilsoft.GeolocationMap.Blazor --version 1.0.0                
NuGet\Install-Package Persilsoft.GeolocationMap.Blazor -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Persilsoft.GeolocationMap.Blazor" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Persilsoft.GeolocationMap.Blazor --version 1.0.0                
#r "nuget: Persilsoft.GeolocationMap.Blazor, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Persilsoft.GeolocationMap.Blazor as a Cake Addin
#addin nuget:?package=Persilsoft.GeolocationMap.Blazor&version=1.0.0

// Install Persilsoft.GeolocationMap.Blazor as a Cake Tool
#tool nuget:?package=Persilsoft.GeolocationMap.Blazor&version=1.0.0                

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 services:

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 76 11/15/2024
1.0.6 90 10/16/2024
1.0.5 128 8/18/2024
1.0.4 130 7/20/2024
1.0.3 241 5/22/2024
1.0.2 104 5/22/2024
1.0.1 265 4/24/2024
1.0.0 100 4/20/2024