gpt4 book ai didi

javascript - 试图将笔记本电脑当前位置发送到服务器并显示在谷歌地图上

转载 作者:行者123 更新时间:2023-11-28 03:34:52 25 4
gpt4 key购买 nike

您好,正如问题所说,我正在尝试使用地理定位将我的笔记本电脑当前位置发送到我的网站,以便它可以在 Google map 上显示其当前位置。到目前为止,我的问题是我只能让它显示服务器位置,而让在笔记本电脑上运行的某种形式的脚本发送到服务器是我遇到麻烦的地方,只是想看看是否有人有任何想法解决这个问题,因为它给我带来了一些困难谢谢

if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var coords = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: 15,
center: coords,
mapTypeControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(
document.getElementById("mapContainer"),
mapOptions
);
var marker = new google.maps.Marker({
position: coords,
map: map,
title: "Your current location!"
});
});
} else {
alert("Geolocation API is not supported in your browser.");
}

最佳答案

好吧,既然你没有提供任何你有问题的代码,我不妨给你一个指向官方 Google Maps Golocation API 网站页面的链接:https://developers.google.com/maps/documentation/business/geolocation/ .

关于javascript - 试图将笔记本电脑当前位置发送到服务器并显示在谷歌地图上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15087539/

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