15825682114经纬度查询地点位置位置

49968人阅读
&&&&& 本文主要讲解如何通过百度地图API根据某个经纬度值(地理坐标)查询对应的地址信息以及该地址周边的POI(Point of Interest,兴趣点)信息。&&&&&&百度地图移动版API不仅包含构建地图的基本接口,还集成了众多搜索服务,包括:位置检索、周边检索、范围检索、公交检索、驾乘检索、步行检索、地址信息查询等。&&&&& 百度地图移动版API提供的搜索服务主要是通过初始化MKSearch类,注册搜索结果的监听对象MKSearchListener来实现异步搜索服务。首先需要自定义一个MySearchListener类,它实现MKSearchListener接口,然后通过实现接口中不同的回调方法,来获得对应的搜索结果。MySearchListener类的定义如下:&&&&& /**
* 实现MKSearchListener接口,用于实现异步搜索服务,得到搜索结果
* @author liufeng
public class MySearchListener implements MKSearchListener {
* 根据经纬度搜索地址信息结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetAddrResult(MKAddrInfo result, int iError) {
* 驾车路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetDrivingRouteResult(MKDrivingRouteResult result, int iError) {
* POI搜索结果(范围检索、城市POI检索、周边检索)
* @param result 搜索结果
* @param type 返回结果类型(11,12,21:poi列表 7:城市列表)
* @param iError 错误号(0表示正确返回)
public void onGetPoiResult(MKPoiResult result, int type, int iError) {
* 公交换乘路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetTransitRouteResult(MKTransitRouteResult result, int iError) {
* 步行路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetWalkingRouteResult(MKWalkingRouteResult result, int iError) {
} 说明:上面的类定义只是在说明MKSearchListener类的5个方法的作用,全都是空实现,并未给出具体的实现。根据你要检索的内容,再去具体实现上面对应的方法,就能获取到搜索结果。例如:1)你想通过一个地理坐标(经纬度值)来搜索地址信息,那么只需要具体实现上面的onGetAddrResult()方法就能得到搜索结果;2)如果你想搜索驾车路线信息,只需要具体实现onGetDrivingRouteResult()方法就能得到搜索结果。
紧接着,需要初始化MKSearch类:&&&&& // 初始化MKSearch
mMKSearch = new MKSearch();
mMKSearch.init(mapManager, new MySearchListener()); 经过上面两步之后,就可以通过调用MKSearch所提供的一些检索方法来搜索你想要的信息了。&&&&& 下面给出一个具体的示例:根据某个经纬度值(地理坐标)查询对应的地址信息以及该地址周边的POI(Point of Interest,兴趣点)信息。1)布局文件res/layout/query_address.xml&&&&& &?xml version="1.0" encoding="utf-8"?&
&ScrollView xmlns:android="/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"&
&LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="经度:"
&EditText android:id="@+id/longitude_input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="106.720397"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="纬度:"
&EditText android:id="@+id/latitude_input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="26.597239"
&Button android:id="@+id/query_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="地址查询"
&TextView android:id="@+id/address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
虽然定义了MapView,但是设置了android:visibility="gone"将其隐藏
因为本示例并不需要显示地图,但不定义又不行(baidu map api的要求)
&com.baidu.mapapi.MapView android:id="@+id/map_View"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:visibility="gone"
&/LinearLayout&
&/ScrollView& 2)继承com.baidu.mapapi.MapActivity的Activity类&&&&&&package com.liufeng.
import android.os.B
import android.view.V
import android.view.View.OnClickL
import android.widget.B
import android.widget.EditT
import android.widget.TextV
import com.baidu.mapapi.BMapM
import com.baidu.mapapi.GeoP
import com.baidu.mapapi.MKAddrI
import com.baidu.mapapi.MKDrivingRouteR
import com.baidu.mapapi.MKPoiI
import com.baidu.mapapi.MKPoiR
import com.baidu.mapapi.MKS
import com.baidu.mapapi.MKSearchL
import com.baidu.mapapi.MKTransitRouteR
import com.baidu.mapapi.MKWalkingRouteR
import com.baidu.mapapi.MapA
* 根据经纬度查询地址信息
* @author liufeng
public class QueryAddressActivity extends MapActivity {
// 定义地图引擎管理类
private BMapManager mapM
// 定义搜索服务类
private MKSearch mMKS
private EditText longitudeEditT
private EditText latitudeEditT
private TextView addressTextV
private Button queryB
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.query_address);
// 初始化MapActivity
mapManager = new BMapManager(getApplication());
// init方法的第一个参数需填入申请的API Key
mapManager.init("285B415EBAB2A50ADA7F03C777C4", null);
super.initMapActivity(mapManager);
// 初始化MKSearch
mMKSearch = new MKSearch();
mMKSearch.init(mapManager, new MySearchListener());
// 通过id查询在布局文件中定义的控件
longitudeEditText = (EditText) findViewById(R.id.longitude_input);
latitudeEditText = (EditText) findViewById(R.id.latitude_input);
addressTextView = (TextView) findViewById(R.id.address_text);
queryButton = (Button) findViewById(R.id.query_button);
// 给地址查询按钮设置单击事件监听器
queryButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// 用户输入的经度值
String longitudeStr = longitudeEditText.getText().toString();
// 用户输入的纬度值
String latitudeStr = latitudeEditText.getText().toString();
// 将用户输入的经纬度值转换成int类型
int longitude = (int) (1000000 * Double.parseDouble(longitudeStr));
int latitude = (int) (1000000 * Double.parseDouble(latitudeStr));
// 查询该经纬度值所对应的地址位置信息
mMKSearch.reverseGeocode(new GeoPoint(latitude, longitude));
} catch (Exception e) {
addressTextView.setText("查询出错,请检查您输入的经纬度值!");
protected boolean isRouteDisplayed() {
protected void onDestroy() {
if (mapManager != null) {
// 程序退出前需调用此方法
mapManager.destroy();
mapManager =
super.onDestroy();
protected void onPause() {
if (mapManager != null) {
// 终止百度地图API
mapManager.stop();
super.onPause();
protected void onResume() {
if (mapManager != null) {
// 开启百度地图API
mapManager.start();
super.onResume();
* 内部类实现MKSearchListener接口,用于实现异步搜索服务
* @author liufeng
public class MySearchListener implements MKSearchListener {
* 根据经纬度搜索地址信息结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetAddrResult(MKAddrInfo result, int iError) {
if (result == null) {
StringBuffer sb = new StringBuffer();
// 经纬度所对应的位置
sb.append(result.strAddr).append("/n");
// 判断该地址附近是否有POI(Point of Interest,即兴趣点)
if (null != result.poiList) {
// 遍历所有的兴趣点信息
for (MKPoiInfo poiInfo : result.poiList) {
sb.append("----------------------------------------").append("/n");
sb.append("名称:").append(poiInfo.name).append("/n");
sb.append("地址:").append(poiInfo.address).append("/n");
sb.append("经度:").append(poiInfo.pt.getLongitudeE6() / f).append("/n");
sb.append("纬度:").append(poiInfo.pt.getLatitudeE6() / f).append("/n");
sb.append("电话:").append(poiInfo.phoneNum).append("/n");
sb.append("邮编:").append(poiInfo.postCode).append("/n");
// poi类型,0:普通点,1:公交站,2:公交线路,3:地铁站,4:地铁线路
sb.append("类型:").append(poiInfo.ePoiType).append("/n");
// 将地址信息、兴趣点信息显示在TextView上
addressTextView.setText(sb.toString());
* 驾车路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetDrivingRouteResult(MKDrivingRouteResult result, int iError) {
* POI搜索结果(范围检索、城市POI检索、周边检索)
* @param result 搜索结果
* @param type 返回结果类型(11,12,21:poi列表 7:城市列表)
* @param iError 错误号(0表示正确返回)
public void onGetPoiResult(MKPoiResult result, int type, int iError) {
* 公交换乘路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetTransitRouteResult(MKTransitRouteResult result, int iError) {
* 步行路线搜索结果
* @param result 搜索结果
* @param iError 错误号(0表示正确返回)
public void onGetWalkingRouteResult(MKWalkingRouteResult result, int iError) {
}&& 3)AndroidManifest.xml中的配置&&&&& &?xml version="1.0" encoding="utf-8"?&
&manifest xmlns:android="/apk/res/android"
package="com.liufeng.baidumap"
android:versionCode="1"
android:versionName="1.0"&
&application android:icon="@drawable/icon" android:label="@string/app_name"&
&activity android:name=".QueryAddressActivity" android:label="@string/app_name"&
&intent-filter&
&action android:name="android.intent.action.MAIN" /&
&category android:name="android.intent.category.LAUNCHER" /&
&/intent-filter&
&/activity&
&/application&
&uses-sdk android:minSdkVersion="4" /&
&!-- 访问网络的权限 --&
&uses-permission android:name="android.permission.INTERNET" /&
&!-- 访问精确位置的权限 --&
&uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&
&!-- 访问网络状态的权限 --&
&uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&
&!-- 访问WIFI网络状态的权限 --&
&uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&
&!-- 改变WIFI网络状态的权限 --&
&uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&
&!-- 读写存储卡的权限 --&
&uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&
&!-- 读取电话状态的权限 --&
&uses-permission android:name="android.permission.READ_PHONE_STATE" /&
&/manifest& 4)运行结果截图及说明&&&&& 程序在模拟器上运行的初始效果如上图所示。可以看出,地图并没有显示出来,这和我们在设计时布局时所设想的一样;另外两个输入框中也分别显示了默认给出的经纬度值。&&&&& 点击&地址查询&按钮后,将看到如下图所示包含了查询结果的界面:&&&&& 说明:图上的&贵州省贵阳市云岩区普陀路&正是我们要查询的地理坐标(经度:106.720397,纬度:26.597239)所对应的地址信息;同时该地址信息下方还显示出了该地址附近的10个兴趣点(POI),每个兴趣点分别包含了&名称&、&地址&、&经纬度&、&电话&、&邮编&和&兴趣点类型&信息。
备注:如果本文的示例继续做下去,就应该将MapView显示出来,同时结合第8篇文章&&所介绍的内容将地址信息和兴趣点标注在地图上。我想这两方面的内容都已做过详细讲解并给出了示例,再来实现这个应该并不是什么难事,看文章的你就动动手来完成它吧!
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:2675682次
积分:13160
积分:13160
排名:第381名
原创:55篇
评论:3795条
难度:高级
类型:技术教程
难度:高级
类型:实战教学
文章:22篇
阅读:1784785
(1)(2)(1)(2)(4)(1)(4)(3)(1)(5)(2)(6)(1)(1)(1)(1)(1)(15)(4)温馨提示:关注海运网平台微信后,请回复LY,即增200元蓝银。
总计706条记录
首页 前一页 当前为第1页
港口名称(英文)
港口名称(中文)
红海/地中海
巴布亚新几内亚
总计706条记录
首页 前一页 当前为第1页
24小时新闻排行
类别:媒体报道
类别:媒体报道
类别:媒体报道
国际危规:IP地址查询_实用工具_1616网址导航 实用工具&&chaxun.1616.net
>> IP地址查询
& & & IP地址查询:请输入IP地址或域名:注: 域名不包括 http:// 您查询的IP为:IP详细信息为:
小常识IP是英文Internet Protocol的缩写,意思是“网络之间互连的协议”,IP协议也可以叫做“因特网协议”。通俗的讲:IP地址也可以称为互联网地址或Internet地址,是用来唯一标识互联网上计算机的逻辑地址。每台连网计算机都依靠IP地址来标识自己,就很类似于我们的电话号码一样,通过电话号码来找到相应的电话,全世界的电话号码都是唯一的。IP地址也是一样。手机号码归属地
手机归属地查询:请输入您所查询的手机号码,点击确定,便可查询该手机号码的所在地。
<label for="p手机归属地查询
手机在线查询
手机号码归属地查询网 - 主要提供移动、联通、电信手机号码归属地查询、归属地的区号,以及卡号类型等相关手机号码查询服务!
移动号码归属地查询支持号段:
134 135 136 137 138 139 150 151 152 157 158 159 182 183 187 188 147
联通号码归属地查询支持号段:
130 131 132 155 156 186 145
电信号码归属地查询支持号段:
133 153 189&手机号查询
--准确判断陌生电话号码所在地
请输入手机号码:

我要回帖

更多关于 手机位置查询 的文章

 

随机推荐