yandex定位 也就是通过坐标获取地理位置
直接上代码

1.首先先创建一个实体类名字gsm_cells

/*** 一组对象,每个对象描述一个单元格*/
public class gsm_cells {private int countrycode;//国家代码private int operatorid;//移动网络代码。private int cellid;//Cell idprivate int lac;//位置代码private int signal_strength;//信号强度private int age;//接收数据以来的时间(以毫秒为单位)public int getCountrycode() {return countrycode;}public void setCountrycode(int countrycode) {this.countrycode = countrycode;}public int getOperatorid() {return operatorid;}public void setOperatorid(int operatorid) {this.operatorid = operatorid;}public int getCellid() {return cellid;}public void setCellid(int cellid) {this.cellid = cellid;}public int getLac() {return lac;}public void setLac(int lac) {this.lac = lac;}public int getSignal_strength() {return signal_strength;}public void setSignal_strength(int signal_strength) {this.signal_strength = signal_strength;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public gsm_cells(int countrycode, int operatorid, int cellid, int lac, int signal_strength, int age) {super();this.countrycode = countrycode;this.operatorid = operatorid;this.cellid = cellid;this.lac = lac;this.signal_strength = signal_strength;this.age = age;}}

2.创建接口实现类wifi_networks

/*** 一组对象,每个对象描述一个Wi-Fi接入点*/
public class wifi_networks {private String mac;//没有分隔符的字符表示中的MAC地址private int signal_strength;//在移动设备的位置处测量的信号强度private int age;//接收数据以来的时间(以毫秒为单位)public String getMac() {return mac;}public void setMac(String mac) {this.mac = mac;}public int getSignal_strength() {return signal_strength;}public void setSignal_strength(int signal_strength) {this.signal_strength = signal_strength;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}public wifi_networks(String mac, int signal_strength, int age) {super();this.mac = mac;this.signal_strength = signal_strength;this.age = age;}
}

3.我需要的是map类型数据 创建SendJson类


public class SendJson {private Map common;private Map ip;public Map getCommon() {return common;}public void setCommon(Map common) {this.common = common;}public Map getIp() {return ip;}public void setIp(Map ip) {this.ip = ip;}public SendJson(Map common, Map ip) {super();this.common = common;this.ip = ip;}}

4.主方法Positioning

public class Positioning {public static void main(String[] args) throws UnsupportedEncodingException {@SuppressWarnings("deprecation")CloseableHttpClient httpClient = HttpClients.createDefault();Map commonChildMap = new HashMap();//纬度的API版本commonChildMap.put("version", "1.0");//定位器API访问密钥commonChildMap.put("api_key", "这里是你的key");Map ipChildMap = new HashMap();ipChildMap.put("address_v4", "95.108.173.231");JSONObject json = JSONObject.fromObject(new SendJson(commonChildMap,ipChildMap)); //,gsmCells,wifiNetworksSystem.out.println(json);HttpGet httpGet = new HttpGet("https://api.lbs.yandex.net/geolocation?json="+URLEncoder.encode(json.toString(), "UTF-8") );httpGet.setHeader("Content-Type", "application/json;charset=UTF-8");// post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中// 响应模型CloseableHttpResponse response = null;try {// 由客户端执行(发送)Post请求response = httpClient.execute(httpGet);// 从响应模型中获取响应实体HttpEntity responseEntity = response.getEntity();System.out.println("响应状态为:" + response.getStatusLine());if (responseEntity != null) {System.out.println("响应内容长度为:" + responseEntity.getContentLength());System.out.println("响应内容为:" + EntityUtils.toString(responseEntity));}} catch (ClientProtocolException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}  finally {try {// 释放资源if (httpClient != null) {httpClient.close();}if (response != null) {response.close();}} catch (IOException e) {e.printStackTrace();}}}
}

5.成功后控制台输出200状态码

响应状态为:HTTP/1.1 200 Ok
响应内容长度为:226
响应内容为:{
“position”:
{
“latitude”:55.75321578979492,
“longitude”:37.62250518798828,
“altitude”:0.0,
“precision”:100000.0,
“altitude_precision”:30.0,
“type”:“ip”
}
}

yandex定位插件相关推荐

  1. flutter 获取定位_从头开发一个Flutter插件(二)高德地图定位插件

    在上一篇文章从头开发一个Flutter插件(一)开发流程里具体介绍了flutter插件的具体开发流程,从创建项目到发布.接下来将会为Flutter天气项目开发一个基于高德定位sdk的flutter定位 ...

  2. 使用plugman开发cordova 高德地图定位插件

    在开发的过程中我们更多的是使用别人开发的cordova插件,但是在使用的过程中经常会遇到一些不合自己心意的问题,那么我们就来使用plugman开发一个属于自己的cordova插件吧. 源码地址 : h ...

  3. 免费资源分享(六) Unity3D 雷达实时定位插件

    免费分享 Unity3D 雷达实时定位插件. 适应版本:Unity 2018.4 链接:https://pan.baidu.com/s/1kE6uTSs70liY2l7GK3r7Eg 提取码:7dw1 ...

  4. vue 高德地图 定位插件 地图实例插件 获取点击的地方的经纬度和具体地址

    npm 安装 推荐 npm 安装. npm install vue-amap --saveimport VueAMap from 'vue-amap';Vue.use(VueAMap); VueAMa ...

  5. js开源定位插件(完全免费)

    插件背景 相信很多人最近都收到某度等地图应用商发来的通知,因为政策等原因,地图应用的使用需要商业授权,而我司之前使用的某度地图商业授权一年要五万!然而绝大部分公司使用的功能仅仅只是浏览器定位,省市区三 ...

  6. 定位插件_微创新 | 开发PL/SQL插件,快速定位所需字段

    点击上方蓝字?加入我们吧!成果ID:96749项目简介 PL/SQL Developer是公司数据支撑人员常年使用的数据库操作软件,提供了众多便利的功能.但同时还有一些地方可以优化,使其更适合我们的使 ...

  7. 定位插件_谷歌官方发布了一款全新超实用Chrome插件,支持国内使用!

    近期,谷歌官方开发并上架Chrome商店一款网页锚文本分享工具:Link to Text Fragment插件.它可以将网页文本以url的形式分享出去,当访问者打开这个url时,能够直接在该网页上定位 ...

  8. xposed定位插件_模拟位置xposed

    模拟位置xposed软件是一款专门为用户们提供超多精准定位服务软件.还可以直接利用缩小地图以及搜索实现更多全球的搜索模拟等定位.在这里利用全新的加密通道不断的去保护用户们的所有网络信息,避免许多的网络 ...

  9. Flutter百度地图定位插件与地理围栏插件冲突问题

    我在开发app签到功能时使用了百度地图sdk,我的需求是需要定位当期那位置并在当前位置限定范围距离内的位置才可以打卡,并且要在地图上进行展示.所以也就需要同时用到定位组件LocationFlutter ...

  10. 微信小程序使用高德小程序定位插件amap易忽略问题

    1.入门指南-微信小程序插件 | 高德地图API 要点: 1.一定要设置 request 请求域名.否则非开发工具环境是,接口请求会失败,而且还不会有什么提示,在开发工具上还能正常使用 2.app.j ...

最新文章

  1. 别找了,Thonny 才是 Python 小白的最理想的 IDE
  2. 写一个易于维护使用方便性能可靠的Hybrid框架(一)—— 思路构建
  3. Qt界面设计器中的界面预览与程序运行时界面不一样
  4. 看CarbonData如何用四招助力Apache Spark
  5. 《天天数学》连载07:一月七日
  6. 分组聚合查询两门以上MySQL_MySQL中的分组聚合查询
  7. Java原始客户端操作Mongodb 增删改查
  8. 数据库的Timeout
  9. 《网页设计技巧》系列之一 浅谈文本排版
  10. 如何破解加密的PDF文件
  11. 数学计算机学具制作,《 用计算器计算》四年级数学
  12. EXCEL条件筛选函数
  13. 力叩经典题--俩数之和
  14. “豫”见超融合,私有云浪潮开启新一线
  15. Ubuntu下安装LXDE+XRDP实现远程桌面访问(最轻量级桌面)
  16. ImageIO.read(inputStream)读取.webp格式图片报错
  17. 输入框过滤表情和颜文字
  18. 小米-测试工程师面试20190418
  19. 关于MOS管的详细介绍
  20. 香农采样定理和奈奎斯特采样定理

热门文章

  1. 易速联服务器稳定吗,异速联如何保障应用安全性?
  2. 黑客攻防从入门到精通 1-6章
  3. C# 怎么生成DLL文件(转)
  4. 创造与魔法服务器多久维护一次,创造与魔法维护大概多久 | 手游网游页游攻略大全...
  5. java oracle 建表语句_oracle得到建表语句
  6. 在微信公众平台做HTML 5游戏的一些经验
  7. NXP RT1062 flashloader下载程序到RAM执行
  8. nodejs利用tinyPNG的API批量压缩图像文件
  9. 《概率论与数理统计》
  10. 基于H5的移动端APP开发框架