gpt4 book ai didi

javascript - 如何在服务器端 Blazor 中使用 Bing Javascript map ?

转载 作者:行者123 更新时间:2023-11-30 06:14:57 25 4
gpt4 key购买 nike

我正在尝试使用 Bing JavaScript Map control在新的 (3.0.0-preview6.19307.2) Blazor server-side application .我已经在早期版本的 Blazor 和客户端应用程序中使用过它。

current Blazor JavaScript interop guide不建议需要任何新步骤,但是当我在 _Hosts.cshtml 的正文中添加以下部分并调用 createMap 函数时,我收到一条错误消息

Microsoft.AspNetCore.Components.Browser.Rendering.RemoteRenderer:

Warning: Unhandled exception rendering component: 'Microsoft' is not defined

ReferenceError: 'Microsoft' is not defined at window.createMap (https://localhost:44372/:79:9)

   <script type="text/javascript" src="http://www.bing.com/api/maps/mapcontrol"></script>

<script>

var map = null;
window.createMap = (data) => {
if (map != null)
return;
map = new Microsoft.Maps.Map('#myMap',
{
credentials: '... my credentials ...',
zoom: 1
}
);
Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap');
return ;
};
</script>

此代码确实在等效客户端大小的 Blazor 项目的 index.html 中时可以正常工作,因此我猜测需要一些额外的步骤才能将映射导出到 Microsoft namespace .谁能建议我缺少什么?

最佳答案

Mister Magoo 的帮助下回答我自己的问题......

在这种特殊情况下,答案似乎是 Blazore 服务器端模型需要到 bing map 控件的 HTTPS(而非 HTTP)连接。

关于javascript - 如何在服务器端 Blazor 中使用 Bing Javascript map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56686469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com