diff --git a/BlazorDeviceInterop.Components/BlazorDeviceInterop.Components.csproj b/BlazorDeviceInterop.Components/BlazorDeviceInterop.Components.csproj
deleted file mode 100644
index 59065df..0000000
--- a/BlazorDeviceInterop.Components/BlazorDeviceInterop.Components.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- netstandard2.0
- 3.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/BlazorDeviceInterop.Components/InteropObject.cs b/BlazorDeviceInterop.Components/InteropObject.cs
deleted file mode 100644
index 24bd17f..0000000
--- a/BlazorDeviceInterop.Components/InteropObject.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.JSInterop;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components
-{
- public abstract class InteropObject
- {
- protected JsRuntimeObjectRef _jsObjRef;
-
- [JsonPropertyName("__jsObjRefId")]
- public int JsObjectRefId { get { return _jsObjRef.JsObjectRefId; } }
-
- public async Task BindToJsRuntime(IJSRuntime jsRuntime)
- {
- _jsObjRef = await CreateJsObjectRef(jsRuntime);
- _jsObjRef.JSRuntime = jsRuntime;
- }
-
- protected abstract Task CreateJsObjectRef(IJSRuntime jsRuntime);
- }
-}
diff --git a/BlazorDeviceInterop.Components/JsRuntimeObjectRef.cs b/BlazorDeviceInterop.Components/JsRuntimeObjectRef.cs
deleted file mode 100644
index 8d452ef..0000000
--- a/BlazorDeviceInterop.Components/JsRuntimeObjectRef.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Microsoft.JSInterop;
-using System;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components
-{
- public class JsRuntimeObjectRef : IAsyncDisposable
- {
- internal IJSRuntime JSRuntime { get; set; }
-
- [JsonPropertyName("__jsObjRefId")]
- public int JsObjectRefId { get; set; }
-
- public async ValueTask DisposeAsync()
- {
- await JSRuntime.InvokeVoidAsync("deviceInterop.removeObjectRef", JsObjectRefId);
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/InteractiveLayer.cs b/BlazorDeviceInterop.Components/LeafletMap/InteractiveLayer.cs
deleted file mode 100644
index f684870..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/InteractiveLayer.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public abstract class InteractiveLayer : Layer
- {
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/LatLng.cs b/BlazorDeviceInterop.Components/LeafletMap/LatLng.cs
deleted file mode 100644
index 8a99f50..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/LatLng.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class LatLng
- {
- public double Lat { get; set; }
- public double Lng { get; set; }
- public LatLng(double lat, double lng)
- {
- Lat = lat;
- Lng = lng;
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/Layer.cs b/BlazorDeviceInterop.Components/LeafletMap/Layer.cs
deleted file mode 100644
index bf8a1cb..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/Layer.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Microsoft.JSInterop;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public abstract class Layer : InteropObject
- {
- public async Task AddTo(Map map)
- {
- await _jsObjRef.JSRuntime.InvokeVoidAsync("LeafletMap.Layer.addTo", this, map);
- return this;
- }
-
- public async Task Remove()
- {
- await _jsObjRef.JSRuntime.InvokeVoidAsync("LeafletMap.Layer.remove", this);
- return this;
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/LayerOptions.cs b/BlazorDeviceInterop.Components/LeafletMap/LayerOptions.cs
deleted file mode 100644
index 2620fc9..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/LayerOptions.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class LayerOptions
- {
- public string Attribution { get; set; }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor b/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor
deleted file mode 100644
index b3d2c7e..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor
+++ /dev/null
@@ -1,3 +0,0 @@
-@inherits LeafletMapBase
-
-
\ No newline at end of file
diff --git a/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor.cs b/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor.cs
deleted file mode 100644
index 8fa407c..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/LeafletMap.razor.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.AspNetCore.Components;
-using Microsoft.JSInterop;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class LeafletMapBase : ComponentBase
- {
- [Inject] public IJSRuntime JSRuntime { get; set; }
- [Parameter] public Map Map { get; set; }
- [Parameter] public TileLayer TileLayer { get; set; }
-
- protected async override Task OnAfterRenderAsync(bool firstRender)
- {
- if (firstRender)
- {
- await Map.BindToJsRuntime(JSRuntime);
- await TileLayer.BindToJsRuntime(JSRuntime);
- await TileLayer.AddTo(Map);
- }
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/Map.cs b/BlazorDeviceInterop.Components/LeafletMap/Map.cs
deleted file mode 100644
index 4d418f3..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/Map.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.JSInterop;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class Map : InteropObject
- {
- [JsonIgnore] public string ElementId { get; }
- [JsonIgnore] public MapOptions Options { get; }
-
- public Map(string elementId, MapOptions options)
- {
- ElementId = elementId;
- Options = options;
- }
-
- protected override async Task CreateJsObjectRef(IJSRuntime jsRuntime)
- {
- return await jsRuntime.InvokeAsync("LeafletMap.map", ElementId, Options);
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/MapOptions.cs b/BlazorDeviceInterop.Components/LeafletMap/MapOptions.cs
deleted file mode 100644
index 2670d5f..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/MapOptions.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class MapOptions
- {
- public LatLng Center { get; set; }
- public int Zoom { get; set; }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/Marker.cs b/BlazorDeviceInterop.Components/LeafletMap/Marker.cs
deleted file mode 100644
index 4fc563d..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/Marker.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.JSInterop;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class Marker : InteractiveLayer
- {
- [JsonIgnore] public LatLng LatLng { get; }
- [JsonIgnore] public MarkerOptions Options { get; }
-
- public Marker(LatLng latlng, MarkerOptions options)
- {
- LatLng = latlng;
- Options = options;
- }
- protected override async Task CreateJsObjectRef(IJSRuntime jsRuntime)
- {
- return await jsRuntime.InvokeAsync("LeafletMap.marker", LatLng, Options);
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/MarkerOptions.cs b/BlazorDeviceInterop.Components/LeafletMap/MarkerOptions.cs
deleted file mode 100644
index 7b33702..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/MarkerOptions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class MarkerOptions
- {
- }
-}
\ No newline at end of file
diff --git a/BlazorDeviceInterop.Components/LeafletMap/Path.cs b/BlazorDeviceInterop.Components/LeafletMap/Path.cs
deleted file mode 100644
index 12a29d9..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/Path.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public abstract class Path : InteractiveLayer
- {
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/Polyline.cs b/BlazorDeviceInterop.Components/LeafletMap/Polyline.cs
deleted file mode 100644
index 0fbaa84..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/Polyline.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Microsoft.JSInterop;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class Polyline : Path
- {
- [JsonIgnore] public IEnumerable LatLngs { get; }
- [JsonIgnore] public PolylineOptions Options { get; }
-
- public Polyline(IEnumerable latLngs, PolylineOptions options)
- {
- LatLngs = latLngs;
- Options = options;
- }
-
- protected override async Task CreateJsObjectRef(IJSRuntime jsRuntime)
- {
- return await jsRuntime.InvokeAsync("LeafletMap.polyline", LatLngs.ToArray(), Options);
- }
-
- public async Task AddLatLng(LatLng latLng)
- {
- await _jsObjRef.JSRuntime.InvokeVoidAsync("LeafletMap.Polyline.addLatLng", this, latLng);
- return this;
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/PolylineOptions.cs b/BlazorDeviceInterop.Components/LeafletMap/PolylineOptions.cs
deleted file mode 100644
index 4306e73..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/PolylineOptions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class PolylineOptions : LayerOptions
- {
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/TileLayer.cs b/BlazorDeviceInterop.Components/LeafletMap/TileLayer.cs
deleted file mode 100644
index 9c04a8d..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/TileLayer.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.JSInterop;
-using System.Text.Json.Serialization;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class TileLayer : Layer
- {
- [JsonIgnore] public string UrlTemplate { get; }
- [JsonIgnore] public TileLayerOptions Options { get; }
-
- public TileLayer(string urlTemplate, TileLayerOptions options)
- {
- UrlTemplate = urlTemplate;
- Options = options;
- }
-
- protected override async Task CreateJsObjectRef(IJSRuntime jsRuntime)
- {
- return await jsRuntime.InvokeAsync("LeafletMap.tileLayer", UrlTemplate, Options);
- }
- }
-}
diff --git a/BlazorDeviceInterop.Components/LeafletMap/TileLayerOptions.cs b/BlazorDeviceInterop.Components/LeafletMap/TileLayerOptions.cs
deleted file mode 100644
index c5616f9..0000000
--- a/BlazorDeviceInterop.Components/LeafletMap/TileLayerOptions.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace BlazorDeviceInterop.Components.LeafletMap
-{
- public class TileLayerOptions : LayerOptions
- {
- }
-}
diff --git a/BlazorDeviceInterop.Components/wwwroot/device-interop.js b/BlazorDeviceInterop.Components/wwwroot/device-interop.js
deleted file mode 100644
index 15323fd..0000000
--- a/BlazorDeviceInterop.Components/wwwroot/device-interop.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var deviceInterop = deviceInterop || {};
-
-deviceInterop.objRefs = {};
-deviceInterop.objRefId = 0;
-deviceInterop.objRefKey = '__jsObjRefId';
-deviceInterop.storeObjRef = function (obj) {
- var id = deviceInterop.objRefId++;
- deviceInterop.objRefs[id] = obj;
- var objRef = {};
- objRef[deviceInterop.objRefKey] = id;
- return objRef;
-}
-deviceInterop.removeObjectRef = function (id) {
- delete deviceInterop.objRefs[id];
-}
-
-DotNet.attachReviver(function (key, value) {
- if (value &&
- typeof value === 'object' &&
- value.hasOwnProperty(deviceInterop.objRefKey) &&
- typeof value[deviceInterop.objRefKey] === 'number') {
- var id = value[deviceInterop.objRefKey];
- if (!(id in deviceInterop.objRefs)) {
- throw new Error("The JS object reference doesn't exist: " + id);
- }
- const instance = deviceInterop.objRefs[id];
- return instance;
- } else {
- return value;
- }
-});
\ No newline at end of file
diff --git a/BlazorDeviceInterop.Components/wwwroot/leaflet-map/leaflet-map.js b/BlazorDeviceInterop.Components/wwwroot/leaflet-map/leaflet-map.js
deleted file mode 100644
index bc94899..0000000
--- a/BlazorDeviceInterop.Components/wwwroot/leaflet-map/leaflet-map.js
+++ /dev/null
@@ -1,39 +0,0 @@
-window.LeafletMap = {
-
- map: function (id, options) {
- return deviceInterop.storeObjRef(L.map(id, options));
- },
-
- marker: function (latlng, options) {
- return deviceInterop.storeObjRef(L.marker(latlng, options));
- },
-
- polyline: function (latlngs, options) {
- return deviceInterop.storeObjRef(L.polyline(latlngs, options));
- },
-
- tileLayer: function (urlTemplate, options) {
- return deviceInterop.storeObjRef(L.tileLayer(urlTemplate, options));
- },
-
- Layer: {
-
- addTo: function (layer, map) {
- layer.addTo(map);
- },
-
- remove: function (layer) {
- layer.remove();
- }
-
- },
-
- Polyline: {
-
- addLatLng: function (polyline, latlng, latlngs) {
- polyline.addLatLng(latlng, latlngs);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/BlazorDeviceInterop.sln b/BlazorDeviceInterop.sln
index 3da3c89..730e360 100644
--- a/BlazorDeviceInterop.sln
+++ b/BlazorDeviceInterop.sln
@@ -3,12 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorDeviceInterop", "BlazorDeviceInterop\BlazorDeviceInterop.csproj", "{A5E4A38E-AB58-44C0-A781-A2E414A1668E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Darnton.Blazor.DeviceInterop", "Darnton.Blazor.DeviceInterop\Darnton.Blazor.DeviceInterop.csproj", "{A5E4A38E-AB58-44C0-A781-A2E414A1668E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorDeviceTestRig", "BlazorDeviceTestRig\BlazorDeviceTestRig.csproj", "{47389794-07A5-4AC5-AA7A-69E9A4E23089}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorDeviceInterop.Components", "BlazorDeviceInterop.Components\BlazorDeviceInterop.Components.csproj", "{39BFE757-6826-4C20-9B23-737642140243}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,10 +21,6 @@ Global
{47389794-07A5-4AC5-AA7A-69E9A4E23089}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47389794-07A5-4AC5-AA7A-69E9A4E23089}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47389794-07A5-4AC5-AA7A-69E9A4E23089}.Release|Any CPU.Build.0 = Release|Any CPU
- {39BFE757-6826-4C20-9B23-737642140243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {39BFE757-6826-4C20-9B23-737642140243}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {39BFE757-6826-4C20-9B23-737642140243}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {39BFE757-6826-4C20-9B23-737642140243}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/BlazorDeviceInterop/BlazorDeviceInterop.csproj b/BlazorDeviceInterop/BlazorDeviceInterop.csproj
deleted file mode 100644
index 17956c8..0000000
--- a/BlazorDeviceInterop/BlazorDeviceInterop.csproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- netstandard2.0
- 3.0
-
-
-
-
-
-
-
-
-
diff --git a/BlazorDeviceInterop/Geolocation/GeolocationEventArgs.cs b/BlazorDeviceInterop/Geolocation/GeolocationEventArgs.cs
deleted file mode 100644
index c87d8f7..0000000
--- a/BlazorDeviceInterop/Geolocation/GeolocationEventArgs.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace BlazorDeviceInterop.Geolocation
-{
- public class GeolocationEventArgs : EventArgs
- {
- public GeolocationResult GeolocationResult { get; set; }
- }
-}
diff --git a/BlazorDeviceInterop/Geolocation/GeolocationPositionErrorCode.cs b/BlazorDeviceInterop/Geolocation/GeolocationPositionErrorCode.cs
deleted file mode 100644
index eab3eb5..0000000
--- a/BlazorDeviceInterop/Geolocation/GeolocationPositionErrorCode.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace BlazorDeviceInterop.Geolocation
-{
- public enum GeolocationPositionErrorCode
- {
- DEVICE_NOT_SUPPORTED = 0,
- PERMISSION_DENIED = 1,
- POSITION_UNAVAILABLE = 2,
- TIMEOUT = 3
- }
-}
\ No newline at end of file
diff --git a/BlazorDeviceInterop/Geolocation/GeolocationResult.cs b/BlazorDeviceInterop/Geolocation/GeolocationResult.cs
deleted file mode 100644
index 05231df..0000000
--- a/BlazorDeviceInterop/Geolocation/GeolocationResult.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Text.Json.Serialization;
-
-namespace BlazorDeviceInterop.Geolocation
-{
- [Serializable]
- public class GeolocationResult
- {
- public GeolocationPosition Position { get; set; }
- public GeolocationPositionError Error { get; set; }
-
- [JsonIgnore]
- public bool IsSuccess => !(Position is null);
- }
-}
diff --git a/BlazorDeviceInterop/Geolocation/IGeolocationService.cs b/BlazorDeviceInterop/Geolocation/IGeolocationService.cs
deleted file mode 100644
index b8082aa..0000000
--- a/BlazorDeviceInterop/Geolocation/IGeolocationService.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Threading.Tasks;
-
-namespace BlazorDeviceInterop.Geolocation
-{
- public interface IGeolocationService
- {
- Task GetCurrentPosition(PositionOptions options = null);
- Task WatchPosition(PositionOptions options = null);
- void SetWatchPosition(GeolocationResult watchResult);
- event EventHandler WatchPositionReceived;
- Task ClearWatch(long watchId);
- }
-}
diff --git a/BlazorDeviceInterop/_Imports.razor b/BlazorDeviceInterop/_Imports.razor
deleted file mode 100644
index 7728512..0000000
--- a/BlazorDeviceInterop/_Imports.razor
+++ /dev/null
@@ -1 +0,0 @@
-@using Microsoft.AspNetCore.Components.Web
diff --git a/BlazorDeviceTestRig/BlazorDeviceTestRig.csproj b/BlazorDeviceTestRig/BlazorDeviceTestRig.csproj
index 2702995..048f3f9 100644
--- a/BlazorDeviceTestRig/BlazorDeviceTestRig.csproj
+++ b/BlazorDeviceTestRig/BlazorDeviceTestRig.csproj
@@ -6,6 +6,7 @@
+
@@ -14,8 +15,7 @@
-
-
+
diff --git a/BlazorDeviceTestRig/Geolocation/GeolocationPositionExtension.cs b/BlazorDeviceTestRig/Geolocation/GeolocationPositionExtension.cs
index a2db540..c1bfed6 100644
--- a/BlazorDeviceTestRig/Geolocation/GeolocationPositionExtension.cs
+++ b/BlazorDeviceTestRig/Geolocation/GeolocationPositionExtension.cs
@@ -1,5 +1,5 @@
-using BlazorDeviceInterop.Components.LeafletMap;
-using BlazorDeviceInterop.Geolocation;
+using Darnton.Blazor.Leaflet.LeafletMap;
+using Darnton.Blazor.DeviceInterop.Geolocation;
namespace BlazorDeviceTestRig.Geolocation
{
diff --git a/BlazorDeviceTestRig/Pages/Geolocation.razor.cs b/BlazorDeviceTestRig/Pages/Geolocation.razor.cs
index 45cd950..b8c9bf3 100644
--- a/BlazorDeviceTestRig/Pages/Geolocation.razor.cs
+++ b/BlazorDeviceTestRig/Pages/Geolocation.razor.cs
@@ -1,14 +1,16 @@
-using BlazorDeviceInterop.Components.LeafletMap;
-using BlazorDeviceInterop.Geolocation;
+using Darnton.Blazor.Leaflet.LeafletMap;
+using Darnton.Blazor.DeviceInterop.Geolocation;
using BlazorDeviceTestRig.Geolocation;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
+using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
namespace BlazorDeviceTestRig.Pages
{
- public class GeolocationBase : ComponentBase
+ public class GeolocationBase : ComponentBase, IDisposable
{
[Inject] public IJSRuntime JSRuntime { get; set; }
[Inject] public IGeolocationService GeolocationService { get; set; }
@@ -31,7 +33,7 @@ namespace BlazorDeviceTestRig.Pages
protected GeolocationResult LastWatchPositionResult { get; set; }
protected string LastWatchLatitude => LastWatchPositionResult?.Position?.Coords?.Latitude.ToString("F2");
protected string LastWatchLongitude => LastWatchPositionResult?.Position?.Coords?.Longitude.ToString("F2");
- protected string LastWatchTimestamp => LastWatchPositionResult?.Position?.DateTime.ToString();
+ protected string LastWatchTimestamp => LastWatchPositionResult?.Position?.DateTimeOffset.ToString();
protected string ToggleWatchCommand => isWatching ? "Stop watching" : "Start watching";
public GeolocationBase() : base()
@@ -77,8 +79,7 @@ namespace BlazorDeviceTestRig.Pages
{
if (isWatching)
{
- GeolocationService.WatchPositionReceived -= HandleWatchPositionReceived;
- await GeolocationService.ClearWatch(WatchHandlerId.Value);
+ await StopWatching();
WatchHandlerId = null;
foreach (var marker in WatchMarkers)
{
@@ -96,6 +97,12 @@ namespace BlazorDeviceTestRig.Pages
StateHasChanged();
}
+ private async Task StopWatching()
+ {
+ GeolocationService.WatchPositionReceived -= HandleWatchPositionReceived;
+ await GeolocationService.ClearWatch(WatchHandlerId.Value);
+ }
+
private async void HandleWatchPositionReceived(object sender, GeolocationEventArgs e)
{
LastWatchPositionResult = e.GeolocationResult;
@@ -120,5 +127,13 @@ namespace BlazorDeviceTestRig.Pages
}
StateHasChanged();
}
+
+ public async void Dispose()
+ {
+ if (isWatching)
+ {
+ await StopWatching();
+ }
+ }
}
}
diff --git a/BlazorDeviceTestRig/Program.cs b/BlazorDeviceTestRig/Program.cs
index 2e70972..9e16dad 100644
--- a/BlazorDeviceTestRig/Program.cs
+++ b/BlazorDeviceTestRig/Program.cs
@@ -1,13 +1,9 @@
using System;
using System.Net.Http;
-using System.Collections.Generic;
using System.Threading.Tasks;
-using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
-using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using BlazorDeviceInterop.Geolocation;
+using Darnton.Blazor.DeviceInterop.Geolocation;
namespace BlazorDeviceTestRig
{
diff --git a/BlazorDeviceTestRig/_Imports.razor b/BlazorDeviceTestRig/_Imports.razor
index 2645751..a890c37 100644
--- a/BlazorDeviceTestRig/_Imports.razor
+++ b/BlazorDeviceTestRig/_Imports.razor
@@ -6,6 +6,6 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
-@using BlazorDeviceInterop.Components.LeafletMap
+@using Darnton.Blazor.Leaflet.LeafletMap
@using BlazorDeviceTestRig
@using BlazorDeviceTestRig.Shared
diff --git a/BlazorDeviceTestRig/wwwroot/index.html b/BlazorDeviceTestRig/wwwroot/index.html
index b8b41ae..a1c444e 100644
--- a/BlazorDeviceTestRig/wwwroot/index.html
+++ b/BlazorDeviceTestRig/wwwroot/index.html
@@ -23,12 +23,12 @@
🗙
-
+
-
-
+
+