简体   繁体   English

如何在Google Maps Geolocation API中获取笔记本电脑(wifi)的纬度和经度?

[英]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.

相关问题 地理位置:使用纬度和经度填写表格。 Google Maps API - Geolocation: Filling forms with latitude and longitude. Google Maps API 如何获得与Google Maps URL的纬度和经度值相同的Google Geocoder API几何值(经度和纬度) - How to get the Google Geocoder API geometry values (latitude and longitude) same as Google maps URL latitude and longitude values 如何从Google Maps V3 API获取经度和纬度? - How to get latitude and longitude from google maps v3 api? 如何获取经度和纬度的谷歌在Javascript地图 - how to get longitude and latitude of google maps in javascript 如何使用 HTML5 地理定位或 Google API 获取地址经纬度? - How do I get an addresses latitude-longitude using HTML5 geolocation or Google API? 通过输入邮政编码从谷歌地图 API 获取经度和纬度 - get longitude & latitude from google maps API by entering zipcode 如何通过Google Maps API检索纬度和经度? - How retrieve latitude and longitude via Google Maps API? 如何检查Google Maps API中GRoute上的纬度/经度点? - How to check if a Latitude/Longitude point is on the GRoute in Google Maps API? Google Maps API - 如何在不显示地图的情况下从自动完成获取纬度和经度? - Google Maps API - how to get latitude and longitude from Autocomplete without showing the map? 使用jQuery插件的Google Maps API:如何在点击时获取标记的纬度和经度? - Google Maps API using jQuery Plugin: How to get a marker's latitude and longitude on click?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM