diff --git a/src/components/BootstrapBlazor.BaiduMap/BaiduItem.cs b/src/components/BootstrapBlazor.BaiduMap/BaiduItem.cs deleted file mode 100644 index 91aba17f..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/BaiduItem.cs +++ /dev/null @@ -1,39 +0,0 @@ -// ********************************** -// Densen Informatica 中讯科技 -// 作者:Alex Chow -// e-mail:zhouchuanglin@gmail.com -// ********************************** - - -using System.ComponentModel; - -namespace BootstrapBlazor.Components; - -/// -/// Baidu定位数据类 -/// -public class BaiduItem -{ - /// - /// 状态 - /// - /// - [DisplayName("状态")] - public string? Status { get; set; } - - /// - /// 纬度 - /// - /// - [DisplayName("纬度")] - public decimal Latitude { get; set; } - - /// - /// 经度 - /// - /// - [DisplayName("经度")] - public decimal Longitude { get; set; } - - -} diff --git a/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor b/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor deleted file mode 100644 index 55413fef..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor +++ /dev/null @@ -1,5 +0,0 @@ -@namespace BootstrapBlazor.Components - -
- - diff --git a/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor.cs b/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor.cs deleted file mode 100644 index e3477fab..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/BaiduMap.razor.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -// Website: https://www.blazor.zone or https://argozhang.github.io/ - -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Configuration; -using Microsoft.JSInterop; - -namespace BootstrapBlazor.Components; - -/// -/// 百度地图 BaiduMap 组件 -/// -public partial class BaiduMap : IAsyncDisposable -{ - [Inject] - [NotNull] - private IJSRuntime? JSRuntime { get; set; } - - [Inject] private IConfiguration? config { get; set; } - - /// - /// 获得/设置 错误回调方法 - /// - [Parameter] - public Func? OnError { get; set; } - - /// - /// 获得/设置 BaiduKey - /// 为空则在 IConfiguration 服务获取 "BaiduKey" , 默认在 appsettings.json 文件配置 - /// - [Parameter] - public string? BaiduKey { get; set; } - - /// - /// 获得/设置 style - /// - [Parameter] - public string Style { get; set; } = "height:700px;width:100%;"; - - /// - /// 获得/设置 ID - /// - [Parameter] - public string ID { get; set; } = "container"; - - /// - /// 获得/设置 定位结果回调方法 - /// - [Parameter] - public Func? OnResult { get; set; } - - private IJSObjectReference? Module { get; set; } - private DotNetObjectReference? Instance { get; set; } - - private string key = String.Empty; - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - key = BaiduKey ?? (config?["BaiduKey"]) ?? "abcd"; - Module = await JSRuntime.InvokeAsync("import", "./_content/BootstrapBlazor.BaiduMap/lib/baidu/baidumap.js" + "?v=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); - Instance = DotNetObjectReference.Create(this); - while (!(await Init())) - { - await Task.Delay(500); - } - //await Module!.InvokeVoidAsync("initMaps"); - } - } - - public async Task Init() => await Module!.InvokeAsync("addScript", new object?[] { key, ID, null, null, null }); - - public async Task ResetMaps() => await Module!.InvokeVoidAsync("resetMaps", ID); - - public async Task OnBtnClick(string btn) => await Module!.InvokeVoidAsync(btn); - - /// - /// 获取定位 - /// - public virtual async Task GetLocation() - { - try - { - await Module!.InvokeVoidAsync("geolocation", Instance); - } - catch (Exception e) - { - if (OnError != null) await OnError.Invoke(e.Message); - } - } - - - /// - /// 定位完成回调方法 - /// - /// - /// - [JSInvokable] - public async Task GetResult(BaiduItem geolocations) - { - try - { - if (OnResult != null) await OnResult.Invoke(geolocations); - } - catch (Exception e) - { - if (OnError != null) await OnError.Invoke(e.Message); - } - } - - async ValueTask IAsyncDisposable.DisposeAsync() - { - if (Module is not null) - { - //await Module.InvokeVoidAsync("destroy", Options); - await Module.DisposeAsync(); - } - } - -} diff --git a/src/components/BootstrapBlazor.BaiduMap/BootstrapBlazor.BaiduMap.csproj b/src/components/BootstrapBlazor.BaiduMap/BootstrapBlazor.BaiduMap.csproj deleted file mode 100644 index 3f227bc5..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/BootstrapBlazor.BaiduMap.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 11.0.0 - - - - Bootstrap Blazor BaiduMap 百度地图 组件 - Bootstrap UI BaiduMap components extensions - 1591 - - - - - - - - - - - diff --git a/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/BaiDuMap.html b/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/BaiDuMap.html deleted file mode 100644 index 1ffcf6e6..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/BaiDuMap.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - 百度地图 3.0 - - - - -
- - - \ No newline at end of file diff --git a/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/baidumap.js b/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/baidumap.js deleted file mode 100644 index 38ca5099..00000000 --- a/src/components/BootstrapBlazor.BaiduMap/wwwroot/lib/baidu/baidumap.js +++ /dev/null @@ -1,88 +0,0 @@ -var map = null; -var containerid = null; -export function addScript(key, elementId, dotnetRef, backgroundColor, controlSize) { - if (!key || !elementId) { - return; - } - - containerid = elementId; - let url = "https://api.map.baidu.com/api?v=3.0&ak="; - let scriptsIncluded = false; - - let scriptTags = document.querySelectorAll('body > script'); - scriptTags.forEach(scriptTag => { - if (scriptTag) { - let srcAttribute = scriptTag.getAttribute('src'); - if (srcAttribute && srcAttribute.startsWith(url)) { - scriptsIncluded = true; - return true; - } - } - }); - - if (scriptsIncluded) { - initMapsG(); - return true; - } - - url = url + key + "&callback=initMapsG"; - let script = document.createElement('script'); - script.src = url; - document.body.appendChild(script); - return false; -} -export function resetMaps(elementId) { - initMaps(elementId); -} -function initMapsG() { - initMaps(containerid); -} -function initMaps(elementId) { - // 创建地图实例 - map = new BMap.Map(elementId, { - coordsType: 5 // coordsType指定输入输出的坐标类型,3为gcj02坐标,5为bd0ll坐标,默认为5。指定完成后API将以指定的坐标类型处理您传入的坐标 - }); - // 创建点坐标 - var point = new BMap.Point(116.47496, 39.77856); - // 初始化地图,设置中心点坐标和地图级别 - map.centerAndZoom(point, 15); - //开启鼠标滚轮缩放 - map.enableScrollWheelZoom(true); - map.addControl(new BMap.NavigationControl()); - map.addControl(new BMap.ScaleControl()); - map.addControl(new BMap.OverviewMapControl()); - map.addControl(new BMap.MapTypeControl()); - // 仅当设置城市信息时,MapTypeControl的切换功能才能可用 - map.setCurrentCity("北京"); -} - -export function geolocation(wrapper) { - var geolocation = new BMap.Geolocation(); - // 开启SDK辅助定位 - geolocation.enableSDKLocation(); - geolocation.getCurrentPosition(function (r) { - let geolocationitem; - if (this.getStatus() == BMAP_STATUS_SUCCESS) { - var mk = new BMap.Marker(r.point); - map.addOverlay(mk); - map.panTo(r.point); - console.log('您的位置:' + r.point.lng + ',' + r.point.lat); - let lng = r.point.lng; - let lat = r.point.lat; - geolocationitem= { - "Longitude":lng, - "Latitude" : lat, - "Status": '您的位置:' + r.point.lng + ',' + r.point.lat - }; - } - else { - geolocationitem= { - "Longitude": 0, - "Latitude": 0, - "Status": 'failed' + this.getStatus() - }; - } - wrapper.invokeMethodAsync('GetResult', geolocationitem); - return geolocationitem; - }); -} \ No newline at end of file