Update to Leaflet 0.1.12.

This commit is contained in:
Bernard Darnton
2020-11-23 21:00:41 +13:00
parent db73a789e7
commit 6f40dbb542
5 changed files with 27 additions and 28 deletions
@@ -1,17 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Darnton.Blazor.Leaflet" Version="0.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
<PackageReference Include="Darnton.Blazor.Leaflet" Version="0.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
+2 -2
View File
@@ -20,7 +20,7 @@
{
<p class="bg-light text-danger">Error: @CurrentPositionResult.Error.Message</p>
}
<LeafletMap Map="PositionMap" TileLayer="OpenStreetMapsTileLayer" />
<LeafletMap Map="PositionMap" TileLayer="PositionTileLayer" />
</div>
<div class="my-3">
@@ -38,5 +38,5 @@
</p>
<button class="btn btn-primary my-3" @onclick="TogglePositionWatch">@ToggleWatchCommand</button>
Watch handler id: @WatchHandlerId
<LeafletMap Map="WatchMap" TileLayer="OpenStreetMapsTileLayer" />
<LeafletMap Map="WatchMap" TileLayer="WatchTileLayer" />
</div>
+11 -7
View File
@@ -2,7 +2,6 @@
using Darnton.Blazor.DeviceInterop.Geolocation;
using BlazorDeviceTestRig.Geolocation;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,14 +11,14 @@ namespace BlazorDeviceTestRig.Pages
{
public class GeolocationBase : ComponentBase, IDisposable
{
[Inject] public IJSRuntime JSRuntime { get; set; }
[Inject] public IGeolocationService GeolocationService { get; set; }
protected Map PositionMap;
protected TileLayer OpenStreetMapsTileLayer;
protected TileLayer PositionTileLayer;
protected Marker CurrentPositionMarker;
protected Map WatchMap;
protected TileLayer WatchTileLayer;
protected Polyline WatchPath;
protected List<Marker> WatchMarkers;
@@ -43,12 +42,20 @@ namespace BlazorDeviceTestRig.Pages
Center = new LatLng(-42, 175),
Zoom = 4
});
PositionTileLayer = new TileLayer(
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
new TileLayerOptions
{
Attribution = @"Map data &copy; <a href=""https://www.openstreetmap.org/"">OpenStreetMap</a> contributors, " +
@"<a href=""https://creativecommons.org/licenses/by-sa/2.0/"">CC-BY-SA</a>"
}
);
WatchMap = new Map("geolocationWatchMap", new MapOptions //Centred on New Zealand
{
Center = new LatLng(-42, 175),
Zoom = 4
});
OpenStreetMapsTileLayer = new TileLayer(
WatchTileLayer = new TileLayer(
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
new TileLayerOptions
{
@@ -70,7 +77,6 @@ namespace BlazorDeviceTestRig.Pages
CurrentPositionMarker = new Marker(
CurrentPositionResult.Position.ToLeafletLatLng(), null
);
await CurrentPositionMarker.BindToJsRuntime(JSRuntime);
await CurrentPositionMarker.AddTo(PositionMap);
}
StateHasChanged();
@@ -115,7 +121,6 @@ namespace BlazorDeviceTestRig.Pages
{
WatchMarkers = new List<Marker> { marker };
WatchPath = new Polyline(WatchMarkers.Select(m => m.LatLng), new PolylineOptions());
await WatchPath.BindToJsRuntime(JSRuntime);
await WatchPath.AddTo(WatchMap);
}
else
@@ -123,7 +128,6 @@ namespace BlazorDeviceTestRig.Pages
WatchMarkers.Add(marker);
await WatchPath.AddLatLng(latlng);
}
await marker.BindToJsRuntime(JSRuntime);
await marker.AddTo(WatchMap);
}
StateHasChanged();
-2
View File
@@ -27,8 +27,6 @@
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<script src="_content/Darnton.Blazor.Leaflet/device-interop.js"></script>
<script src="_content/Darnton.Blazor.Leaflet/leaflet-map/leaflet-map.js"></script>
</body>
</html>
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Darnton.Blazor.DeviceInterop</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.1.0</Version>
<Version>0.1.1</Version>
<Authors>Bernard Darnton</Authors>
<Product>Blazor device interop library</Product>
<Description>Blazor device interop library including wrappers for Geolocation API</Description>
<Description>Blazor device interop library including wrappers for Geolocation API. Updated to .NET 5</Description>
<Copyright>2020 Bernard Darnton</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/darnton/BlazorDeviceInterop</RepositoryUrl>
<AssemblyVersion>0.0.1.0</AssemblyVersion>
<FileVersion>0.0.1.0</FileVersion>
<AssemblyVersion>0.0.1.1</AssemblyVersion>
<FileVersion>0.0.1.1</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -23,8 +22,8 @@
<ItemGroup>
<PackageReference Include="Darnton.Units" Version="0.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.0" />
</ItemGroup>
</Project>