Hi Ben,
Thank you for your quick response, it seems the beta114 still not working for me.
I had created my own MVTTileLayer and WmtsLayer to see if they are working or not. But it looks both OnSendingHttpRequestMessage are not hitted.
public class MyMVTTileAysncLayer : MvtTilesAsyncLayer
{
private string _accessToken = string.Empty;
public MyMVTTileAysncLayer(string urlTemplate, string accessToken) : base($"{urlTemplate}?access_token={accessToken}")
{
this._accessToken = accessToken;
}
protected override void OnSendingHttpRequestMessage(SendingHttpRequestMessageEventArgs e)
{
base.OnSendingHttpRequestMessage(e);
}
protected override void OnReceivedHttpResponseMessage(ReceivedHttpResponseMessageEventArgs e)
{
base.OnReceivedHttpResponseMessage(e);
}
}
public class MyWmtsAsyncLayer : WmtsAsyncLayer
{
public MyWmtsAsyncLayer(string uri) : base (new Uri(uri)) { }
protected override void OnSendingHttpRequestMessage(SendingHttpRequestMessageEventArgs e)
{
base.OnSendingHttpRequestMessage(e);
}
protected override void OnReceivedHttpResponseMessage(ReceivedHttpResponseMessageEventArgs e)
{
base.OnReceivedHttpResponseMessage(e);
}
}
Razor
@using ThinkGeo.UI.Blazor
@using ThinkGeo.Core
<!--You can control the width and height in CSS too, if you like. -->
<MapView Id="demomap" MapUnit="@ThinkGeo.Core.GeographyUnit.Meter" Width="800" Height="600">
<OverlaysSetting>
<LayerOverlay Id="MVTLayerOverlay" Layers="@layers" />
</OverlaysSetting>
</MapView>
@code {
GeoCollection<LayerBase> layers = new GeoCollection<LayerBase>();
protected override void OnInitialized()
{
var mvtLayer1 = new MvtTilesAsyncLayer("https://demotiles.maplibre.org/style.json");
layers.Add(mvtLayer1);
// mvtLayer1.OpenAsync();
var wmtsAsyncLayer = new MyWmtsAsyncLayer("https://wmts.geo.admin.ch/1.0.0");
wmtsAsyncLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
wmtsAsyncLayer.ActiveLayerName = "ch.swisstopo.pixelkarte-farbe-pk25.noscale";
wmtsAsyncLayer.ActiveStyleName = "default";
wmtsAsyncLayer.OutputFormat = "image/png";
wmtsAsyncLayer.TileMatrixSetName = "21781_26";
layers.Add(wmtsAsyncLayer);
wmtsAsyncLayer.OpenAsync();
StateHasChanged();
}
}
And another question, is the library support Blazor WebAssembly and Blazor Hybrid or any plans to support in future?
I was also doing POC on WebAssembly but it looks I have these error
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: SystemNetRequests_PlatformNotSupported
System.PlatformNotSupportedException: SystemNetRequests_PlatformNotSupported
at System.Net.WebRequest.get_DefaultWebProxy()
at ThinkGeo.Core.WmtsAsyncLayer..ctor(Uri serverUri)
at BlazorApp2.MyWmtsAsyncLayer..ctor(String uri) in C:\Users\Jimmy Pun\Desktop\BlazorApp2\BlazorApp2\MyWmtsAsyncLayer.cs:line 7
at BlazorApp2.Pages.Home.OnInitialized() in C:\Users\Jimmy Pun\Desktop\BlazorApp2\BlazorApp2\Pages\Home.razor:line 22
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
For Blazor Hybrid, it only shows a empty page.