[英]How get latitude and longitude of laptop (wifi) in Google Maps Geolocation API?
To get latitude and longitude of a mobile phone we can use Google Maps Geolocation API ( https://developers.google.com/maps/documentation/geolocation/intro?hl=en ) by sending a package with the following format: enter image description here 为了得到一个手机就可以使用谷歌地图地理位置API(纬度和经度https://developers.google.com/maps/documentation/geolocation/intro?hl=en通过发送包以下格式): 输入图像这里的描述
The Google Maps Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect. Google Maps Geolocation API根据有关移动客户端可以检测到的基站和WiFi节点的信息来返回位置和精度半径。 However, I wonder that for a laptop, how the format of a sent package will be.
但是,我想知道对于笔记本电脑来说,已发送包裹的格式如何。 Is there anyone willing to send me a sample format used to get the location of a laptop?
有谁愿意给我发送用于获取笔记本电脑位置的样本格式? Thanks so much.
非常感谢。
You can just use 你可以用
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(callback);
}
and browser colls your callback function with one argument like this: 浏览器将您的回调函数与一个参数进行排序,如下所示:
function setLocation(position) {
userPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
};
I'm probably late to answer, but someone might find this useful. 我可能来不及回答,但有人可能会觉得有用。
So, you'll need to Post a request to https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_KEY 因此,您需要将请求发布到https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_KEY
The response will be something like this: 响应将是这样的:
{
"location": {
"lat": 51.0,
"lng": -0.1
},
"accuracy": 1200.4
}
You can get a key from Google Cloud Platform 您可以从Google Cloud Platform获取密钥
All the details of the API are here Geolocation API Documentation API的所有详细信息都在这里Geolocation API文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.