如何获取Geo位置Blazor Server
我目前正在基于.NET 6的Blazor Server项目。需要将GEO位置进入应用程序。我已经尝试了几种方法,但它们不起作用。在那里有人知道吗?请帮我。
I am currently working on a blazor server project based on .NET 6. there is a requirement to get the geo location into the application. I have tried several ways but they don't work.is there anyone who knows about it ?? please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这显示了如何调用浏览器API以获取当前位置。
geolocationjsinterop.js
(wwwroot \ scripts)geolocation.razor
注意:更改
.js
文件的路径以适合您的项目。在这种情况下,我引用了称为chatclient.core
的RCL。args:“ ./scripts/geolocationjsinterop.js”
for root Project。该组件在WASM或Blazor-Server上运行。
api docs
This shows how to call the browser API to get the current position.
geoLocationJsInterop.js
(wwwroot\scripts)GeoLocation.razor
Note: Change the path of the
.js
file to suite your project. In this case I was referencing a RCL calledChatClient.Core
.args: "./scripts/geoLocationJsInterop.js"
for your root project.This component runs on either wasm or blazor-server.
API Docs