BlazorLeafletInterop 4.3.2
dotnet add package BlazorLeafletInterop --version 4.3.2
NuGet\Install-Package BlazorLeafletInterop -Version 4.3.2
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="BlazorLeafletInterop" Version="4.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorLeafletInterop" Version="4.3.2" />
<PackageReference Include="BlazorLeafletInterop" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorLeafletInterop --version 4.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BlazorLeafletInterop, 4.3.2"
#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.
#:package BlazorLeafletInterop@4.3.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorLeafletInterop&version=4.3.2
#tool nuget:?package=BlazorLeafletInterop&version=4.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Blazor Leaflet Interop
It is a work in progress and only supports parts of the Leaflet API.
This project is a component based wrapper around the Leaflet API, but some components can be used outside of RenderTree.
Implemented Components
- Map
- TileLayer
- Marker
- Popup, Tooltip
- Polyline, MultiPolyline
- FeatureGroup, LayerGroup, GeoJSON
- Control.Zoom, Control.Scale, Control.Attribution, Control.Layers
- Icon
- Events (should work but are not tested)
- ImageOverlay, SVGOverlay, VideoOverlay
- Renderers
- Rectangle, Polygon, Circle, CircleMarker
- Bounds, DivIcon
Installation
Install the package from NuGet
dotnet add package BlazorLeaflet
Install-Package BlazorLeafletInterop
Add the latest leaflet version to your index.html
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.js"></script>
Add this service to your Program.cs
// ...Program.cs
builder.Services.AddMapService();
Examples
To make a simple map use the following code
<Map MapOptions="Options">
<TileLayer UrlTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png" />
</Map>
@code {
private MapOptions Options = new MapOptions() {
Center = new LatLng(51.505, -0.09),
Zoom = 13
};
}
Marker Usage
<Map MapOptions="Options">
<TileLayer UrlTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png" />
<Marker LatLng="new LatLng(51.5, -0.0.9)"></Marker>
</Map>
@code {
private MapOptions Options = new MapOptions() {
Center = new LatLng(51.505, -0.09),
Zoom = 13
};
}
Popup Usage
<Map MapOptions="Options">
<TileLayer UrlTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png" />
<Marker LatLng="new LatLng(51.5, -0.0.9)">
<Popup>
<b>Hello world!</b><br>
I am a popup
</Popup>
</Marker>
</Map>
@code {
private MapOptions Options = new MapOptions() {
Center = new LatLng(51.505, -0.09),
Zoom = 13
};
}
Accessing Leaflet Method's
<Map MapOptions="Options">
<TileLayer UrlTemplate="https://tile.openstreetmap.org/{z}/{x}/{y}.png" />
<Marker @ref="MarkerRef" LatLng="new LatLng(51.5, -0.0.9)">
<Popup>
<b>Hello world!</b><br>
I am a popup
</Popup>
</Marker>
</Map>
@code {
// Creating a reference to the component,
// gives you access to the Leaflet methods for that class.
private Marker? MarkerRef;
private MapOptions Options = new MapOptions() {
Center = new LatLng(51.505, -0.09),
Zoom = 13
};
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (MarkerRef is not null) await MarkerRef.OpenPopup();
}
}
Contributing
If you want to contribute to this project, feel free to do so. Just fork the project and create a pull request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- GeoJSON.Text (>= 1.0.2)
- Microsoft.AspNetCore.Components.Web (>= 7.0.12)
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 |
---|---|---|
4.3.2 | 1,674 | 1/19/2024 |
4.3.1 | 139 | 1/19/2024 |
4.3.0 | 228 | 12/15/2023 |
4.2.0 | 188 | 11/28/2023 |
4.1.2 | 167 | 11/13/2023 |
4.1.1 | 114 | 11/13/2023 |
4.1.0 | 137 | 11/13/2023 |
4.0.1 | 127 | 11/13/2023 |
4.0.0 | 123 | 11/12/2023 |
3.3.9 | 174 | 10/31/2023 |
3.3.8 | 159 | 10/31/2023 |
3.3.7 | 169 | 10/30/2023 |
3.3.6 | 159 | 10/29/2023 |
3.3.5 | 151 | 10/29/2023 |
3.3.4 | 151 | 10/29/2023 |
3.3.3 | 172 | 10/26/2023 |
3.3.2 | 159 | 10/26/2023 |
3.3.1 | 170 | 10/26/2023 |
3.2.0 | 149 | 10/25/2023 |
3.1.6 | 180 | 10/25/2023 |
3.1.5 | 153 | 10/25/2023 |
3.1.4 | 178 | 10/24/2023 |
3.1.3 | 175 | 10/24/2023 |
3.1.2 | 184 | 10/24/2023 |
3.1.1 | 172 | 10/24/2023 |
3.1.0 | 158 | 10/24/2023 |
3.0.3 | 168 | 10/20/2023 |
3.0.2 | 178 | 10/20/2023 |
3.0.1 | 159 | 10/19/2023 |
3.0.0 | 160 | 10/19/2023 |
2.1.0 | 178 | 10/18/2023 |
2.0.0 | 158 | 10/18/2023 |
1.0.6 | 183 | 10/17/2023 |
1.0.5 | 150 | 10/17/2023 |
1.0.4 | 175 | 10/17/2023 |
1.0.3 | 168 | 10/17/2023 |
1.0.2 | 169 | 10/16/2023 |