下载百度地图定位当前位置手机号码位置

百度地图定位的封装得到用户所在省份、城市、街道信息。 - 简书
百度地图定位的封装得到用户所在省份、城市、街道信息。
导入百度地图SDK
(需要的是定位功能和检索功能的SDK)
为了方便在多个页面调用 我们可以写一个单例。新建一个类继承自 NSObject
上代码:.h文件
//定位成功的回调 包含海拔 经纬度信息
typedef void(^AFuserLocationCompletion)(BMKUserLocation *userLocation);
//实际的位置信息 省 市
typedef void(^AFReverseGeoCodeResultCompletion)(BMKGeoCodeSearch *searcher,BMKReverseGeoCodeResult *result,BMKSearchErrorCode error);
@interface AFMapManager : NSObject&BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate&{
BMKLocationService *_locS
BMKGeoCodeSearch *_
AFuserLocationCompletion _locationC
AFReverseGeoCodeResultCompletion _ResultC
+ (AFMapManager *)
//获得经纬度
- (void)af_startUserLocationServiceWithCompletion:(AFuserLocationCompletion)
//根据经纬度 获得具体地址
- (void)af_getAddressWithuserLocation:(BMKUserLocation *)userLocation
Completion:(AFReverseGeoCodeResultCompletion)
注意要导入百度地图的头文件
#import &BaiduMapAPI_Location/BMKLocationComponent.h&//引入定位功能所有的头文件
#import &BaiduMapAPI_Search/BMKSearchComponent.h&//引入检索功能所有的头文件
好吧稍微讲解一下:
定义两个方法。
//获得经纬度
- (void)af_startUserLocationServiceWithCompletion:(AFuserLocationCompletion)
第一个方法的作用是获得BMKUserLocation 的一个对象。 其中包含经纬度、海拔等一些信息。 我们下面的方法要根据经纬度获取用户的具体地址信息。
//根据经纬度 获得具体地址
- (void)af_getAddressWithuserLocation:(BMKUserLocation *)userLocation
Completion:(AFReverseGeoCodeResultCompletion)
第二个方法就是得到具体的省份、城市等信息了。
看一下.m里面的实现
@implementation AFMapManager
+ (AFMapManager *)manager{
static AFMapManager *manager =
AFDISPATCH_ONCE_BLOCK(^{
if (!manager) {
manager = [[[self class] alloc] init];
- (instancetype)init{
if (self == [super init]) {
_searcher = [[BMKGeoCodeSearch alloc]init];
_searcher.delegate =
_locService = [[BMKLocationService alloc] init];
_locService.delegate =
- (void)af_startUserLocationServiceWithCompletion:(AFuserLocationCompletion)completion{
_locationCompletion = [completion copy];
[_locService startUserLocationService];
- (void)af_getAddressWithuserLocation:(BMKUserLocation *)userLocation Completion:(AFReverseGeoCodeResultCompletion)completion{
_ResultCompletion = [completion copy];
//发起反地理编码
CLLocationCoordinate2D pt = (CLLocationCoordinate2D){userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude};
//逆向编码对象
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
//设置需要转化的经纬度
reverseGeocodeSearchOption.reverseGeoPoint =
//发送逆向地理编码--》会回调 onGetReverseGeoCodeResult
BOOL flag = [_searcher reverseGeoCode:reverseGeocodeSearchOption];
NSLog(@"反geo检索发送成功");
NSLog(@"反geo检索发送失败");
#pragma mark - BMKLocationServiceDelegate
- (void)willStartLocatingUser {
NSLog(@"location start");
*在停止定位后,会调用此函数
- (void)didStopLocatingUser {
NSLog(@"user location stop");
*用户方向更新后,会调用此函数
*@param userLocation 新的用户位置
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation {
//NSLog(@"user derection change");
*用户位置更新后,会调用此函数
*@param userLocation 新的用户位置
// 地理位置变更信息
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation{
NSLog(@"didUpdateUserLocation lat %f,long %f",
userLocation.location.coordinate.latitude,
userLocation.location.coordinate.longitude);
if (_locationCompletion) {
_locationCompletion(userLocation);
[_locService stopUserLocationService];
*定位失败后,会调用此函数
*@param error 错误号
- (void)didFailToLocateUserWithError:(NSError *)error {
NSLog(@"定位失败");
if (_locationCompletion) {
_locationCompletion(nil);
[_locService stopUserLocationService];
#pragma - 反向地理编码回调
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
if (_ResultCompletion) {
_ResultCompletion(searcher,result,error);
在需要定位到地址的文件里面导入头文件
#import "AFMapManager.h"
[[AFMapManager manager] af_startUserLocationServiceWithCompletion:^(BMKUserLocation *userLocation) {
[[AFMapManager manager] af_getAddressWithuserLocation:userLocation Completion:^(BMKGeoCodeSearch *searcher, BMKReverseGeoCodeResult *result, BMKSearchErrorCode error) {
NSLog(@"地址是 &&%@",result.address);
这样就可以得到用户的地址了。 省、市、街道的信息也可以单独取出来。
/// 城市名称
result.addressDetail.
/// 区县名称
result.addressDetail.district
/// 省份名称
result.addressDetail.province//
/// 街道名称
result.addressDetail.streetName//
/// 街道号码
result.addressDetail.streetNumber//
有兴趣的话可以了解一下 BMKReverseGeoCodeResult 这个类
///反地址编码结果
@interface BMKReverseGeoCodeResult : NSObject
BMKAddressComponent* _addressD
NSString* _
CLLocationCoordinate2D _
NSArray* _poiL
///层次化地址信息
@property (nonatomic, strong) BMKAddressComponent* addressD
///地址名称
@property (nonatomic, strong) NSString*
///商圈名称
@property (nonatomic, strong) NSString* businessC
///地址坐标
@property (nonatomic) CLLocationCoordinate2D
///地址周边POI信息,成员类型为BMKPoiInfo
@property (nonatomic, strong) NSArray* poiL
代码地址:
做无所畏惧的人。android手机端如何用浏览器打开百度地图并且定位到指定坐标_百度地图api吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:5,783贴子:
android手机端如何用浏览器打开百度地图并且定位到指定坐标收藏
如题,android上,我想通过浏览器这种方法访问百度地图,传入一个坐标,并且定位?就是这样类似的,谷歌可以的,实现方法是这样Uri webpage = Uri
.parse("" + posX+ "," + posY);Intent webIntent = new Intent(Intent.ACTION_VIEW,webpage);startActivity(webIntent);运行效果是这样的不知道百度地图可不可以这样实现,求大神指教!!!!!!
思美人同名游戏,画质精良,招式华丽,场面恢宏首服刚开,福利多,元宝好拿!
顶啊,求指导!!!
//获取地图控件引用
mapView = (MapView) findViewById(R.id.mapView);
mBaiduMap=mapView.getMap();
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
mBaiduMap.setMaxAndMinZoomLevel(19, 3);//设置地图的最大最小值范围是3-19
mBaiduMap.setMyLocationEnabled(false);
//定义Maker坐标点
,地图上做标记
LatLng point = new LatLng(28.0.971605);
MapStatus mMapStatus = new MapStatus.Builder().target(point).zoom(18)
MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory
.newMapStatus(mMapStatus);
mBaiduMap.setMapStatus(mMapStatusUpdate);
//构建Marker图标
BitmapDescriptor bitmap = BitmapDescriptorFactory
.fromResource(R.drawable.icon_geo);
//构建MarkerOption,用于在地图上添加Marker
OverlayOptions option = new MarkerOptions()
.position(point)
.icon(bitmap);
//在地图上添加Marker,并显示
mBaiduMap.addOverlay(option);
登录百度帐号推荐应用赞助商链接
百度首家应用增强现实技术,开启摄像头模式,支持离线地图和好友位置共享,提供贴心的屏幕长亮和打车估价功能。通过百度地图,您可以快速进行定位;任意查找地点、商家、公交站点。同时提供多种出行路线规划。此外,提供分城市离线地图包,节省90%以上的流量;支持手机联系人实时的位置共享;更有实时路况、离线收藏、截图、测距、流量监控等各种实用工具。
关键字: ,
&&请点击以下的链接下载该软件:&
软件按字母排列:
中文按声母排列:博客分类:
最近由于项目需要,研究了下百度地图定位,他们提供的实例基本都是用监听器实现自动定位的。我想实现一种效果:当用户进入UI时,不定位,用户需要定位的时候,自己手动点击按钮,再去定位当前位置。
经过2天研究和咨询,找到了解决方案,在此备忘一下。
注意:定位使用真机才能够真正定位;模拟器的话,在DDMS中的Emulator Control中,选择Manual,下面单选按钮选择Decimal,然后填写经纬度,send后,再点击定位我的位置按钮,就能定位了(这应该算是固定定位,哈哈。。。)、
亲,有问题点击联系我哦。
1、第一步当然是获取一个针对自己项目的key值。/wiki/static/imap/key/
2、使用百度API是有前提的,摘自百度:首先将API包括的两个文件baidumapapi.jar和libBMapApiEngine.so拷贝到工程根目录及libs\armeabi目录下,并在工程属性-&Java Build Path-&Libraries中选择“Add JARs”,选定baidumapapi.jar,确定后返回,这样您就可以在您的程序中使用API了。(这两个文件见附件)。
3、按照自己的需求写一个layout,我的如下:
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout
xmlns:android="/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myLocation_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:gravity="center_horizontal"
android:textColor="@drawable/black"
android:background="@drawable/gary"
&com.baidu.mapapi.MapView android:id="@+id/bmapsView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:clickable="true"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/location_button_id"
android:text="@string/location_button_text"
&/LinearLayout&
需要特别注意的是:&com.baidu.mapapi.MapView
/& 这玩意。
4、写一个MapApplication实现application,提供全局的BMapManager,以及其初始化。
public BMapManager mapManager =
static MapA
public String mStrKey = "你申请的key值";
public void onCreate() {
mapManager = new BMapManager(this);
mapManager.init(mStrKey, new MyGeneralListener());
//建议在您app的退出之前调用mapadpi的destroy()函数,避免重复初始化带来的时间消耗
public void onTerminate() {
// TODO Auto-generated method stub
if(mapManager != null)
mapManager.destroy();
mapManager =
super.onTerminate();
static class MyGeneralListener implements MKGeneralListener{
public void onGetNetworkState(int arg0) {
Toast.makeText(MapApplication.app.getApplicationContext(), "您的网络出错啦!",
Toast.LENGTH_LONG).show();
public void onGetPermissionState(int iError) {
if (iError ==
MKEvent.ERROR_PERMISSION_DENIED) {
// 授权Key错误:
Toast.makeText(MapApplication.app.getApplicationContext(),"您的授权Key不正确!",
Toast.LENGTH_LONG).show();
5、接下来就是按照百度api写定位代码了,使用handler机制去添加定位图层,需要说明的都在注释上了。
private BMapManager mBMapMan =
private MapView mMapView =
private MapController bMapC
private MKLocationManager mkLocationM
private MKSearch mkS
private TextView address_
//定位到的位置信息
private ProgressD
private List&HotelInfo& hotelL
private int distance = 1000;
//查询的范围(单位:m)
Handler handler = new Handler(){
public void handleMessage(Message msg) {
double lat = msg.getData().getDouble("lat");
double lon = msg.getData().getDouble("lon");
if(lat!=0&&lon!=0){
GeoPoint point = new GeoPoint(
(int) (lat * 1E6),
(int) (lon * 1E6));
bMapController.animateTo(point);
//设置地图中心点
bMapController.setZoom(15);
mkSearch.reverseGeocode(point);
//解析地址(异步方法)
MyLocationOverlay myLoc = new MyLocationOverlayFromMap(ShowMapAct.this,mMapView);
myLoc.enableMyLocation();
// 启用定位
myLoc.enableCompass();
// 启用指南针
mMapView.getOverlays().add(myLoc);
Toast.makeText(ShowMapAct.this, "没有加载到您的位置", Toast.LENGTH_LONG).show();
if(hotelList!=null){
Drawable marker = getResources().getDrawable(R.drawable.iconmarka);
//设置marker
marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
//为maker定义位置和边界
mMapView.getOverlays().add(new OverItemList(marker,hotelList,ShowMapAct.this,bMapController));
}else if(hotelList==null&&lat!=0&&lon!=0){
Toast.makeText(ShowMapAct.this, "网络异常,没有获取到酒店信息。", Toast.LENGTH_LONG).show();
if(dialog!=null)
dialog.dismiss();
protected void onCreate(Bundle savedInstanceState) {
distance = getIntent().getExtras().getInt("distance");
//获取查询范围
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
mMapView = (MapView)findViewById(R.id.bmapsView);
//初始化一个mapView
//初始化地图管理器
super.initMapActivity(mBMapMan);
address_view = (TextView)findViewById(R.id.myLocation_id);
SpannableStringBuilder style = new SpannableStringBuilder(String.format(getResources().getString(R.string.location_text),"位置不详"));
style.setSpan(new ForegroundColorSpan(Color.RED), 5, style.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
address_view.setText(style);
Button location_button = (Button)findViewById(R.id.location_button_id);
location_button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
dialog = ProgressDialog.show(ShowMapAct.this, "", "数据加载中,请稍后.....");
new Thread(new MyThread()).start();
mkSearch = new MKSearch();
//初始化一个MKSearch,根据location解析详细地址
mkSearch.init(mBMapMan, this);
mMapView.setBuiltInZoomControls(true);
//启用内置的缩放控件
bMapController = mMapView.getController();
GeoPoint defaultPoint = new GeoPoint((int) (39.920934 * 1E6),(int) (116.412817 * 1E6));
//用给定的经纬度构造一个GeoPoint,单位是微度 (度 * 1E6)
bMapController.setCenter(defaultPoint);
//设置地图中心点
bMapController.setZoom(12);
//设置地图zoom级别
mkLocationManager = mBMapMan.getLocationManager();
* 初始化地图管理器BMapManager
public void init(){
MapApplication app = (MapApplication)getApplication();
if (app.mapManager == null) {
app.mapManager = new BMapManager(getApplication());
app.mapManager.init(app.mStrKey, new MapApplication.MyGeneralListener());
mBMapMan = app.mapM
protected void onDestroy() {
MapApplication app = (MapApplication)getApplication();
if (mBMapMan != null) {
mBMapMan.destroy();
app.mapManager.destroy();
app.mapManager =
mBMapMan =
super.onDestroy();
protected void onPause() {
if (mBMapMan != null) {
// 终止百度地图API
mBMapMan.stop();
super.onPause();
protected void onResume() {
if (mBMapMan != null) {
// 开启百度地图API
mBMapMan.start();
super.onResume();
protected boolean isRouteDisplayed() {
public void onGetAddrResult(MKAddrInfo result, int iError) {
if(result==null)
SpannableStringBuilder style = new SpannableStringBuilder(String.format(getResources().getString(R.string.location_text),result.strAddr));
style.setSpan(new ForegroundColorSpan(Color.RED), 5, style.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
address_view.setText(style);
if(dialog!=null) dialog.dismiss();
public void onGetDrivingRouteResult(MKDrivingRouteResult arg0, int arg1) {}
public void onGetPoiResult(MKPoiResult arg0, int arg1, int arg2) {}
public void onGetTransitRouteResult(MKTransitRouteResult arg0, int arg1) {}
public void onGetWalkingRouteResult(MKWalkingRouteResult arg0, int arg1) {}
* 重新定位,加载数据
* @author Administrator
class MyThread implements Runnable{
public void run() {
* 最重要的就是这个玩意
* 由于LocationListener获取第一个位置修正的时间会很长,为了避免用户等待,
* 在LocationListener获取第一个更精确的位置之前,应当使用getLocationInfo() 获取一个缓存的位置
Location location = mkLocationManager.getLocationInfo();
double lat = 0d,lon = 0d;
if(location!=null){
//定位到位置
String coordinate = location.getLatitude()+","+location.getLongitude();
HotelRemoteData hotelData = new HotelRemoteData();
* 远程获取酒店列表数据
hotelList = hotelData.getHotelToMap(coordinate,distance);
lat = location.getLatitude();
lon = location.getLongitude();
Message msg = new Message();
Bundle data = new Bundle();
data.putDouble("lat", lat);
data.putDouble("lon", lon);
msg.setData(data);
handler.sendMessage(msg);
6、还有一种就是百度示例相当推荐的,也是加载定位位置速度比较快的,那就是通过定位监听器来定位信息。没啥难的,照着百度的示例写,都能搞定。
LocationListener listener = new LocationListener() {
/** 位置变化,百度地图即会调用该方法去获取位置信息。
* (我测试发现就算手机不动,它也会偶尔重新去加载位置;只要你通过重力感应,他就一定会重新加载)
public void onLocationChanged(Location location) {
GeoPoint gp =
new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6));
//通过地图上的经纬度转换为地图上的坐标点
bMapController.animateTo(gp);
//动画般的移动到定位的位置
(583.6 KB)
下载次数: 1058
浏览 47577
:D 不错,看看,需要[*][/list][/img][/img][/img][/url][/flash][/flash][/flash][/flash]||||||||||||||||||||||||||||||||||||&
博主,能给我发一份文件吗& ??邮箱:这个应该是几年前做的东西了,源码已没有。不过百度的API现在搞的很齐全,仿照着应该很好做。
浏览: 609244 次
来自: 北京
不错,谢谢分享!推荐个参考视频内容:http://www.ro ...
完全正确,补充一下&beans:bean id=&quo ...
longToip直接用ipToLong反过来就好了 publi ...
[size=x-small]jatoolsPrinter还有破 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'百度通地图定位 1.8.6
相关合集:
相关热搜:
百度云盘怎么搜索资源?目前能正常使用的云盘只剩百度云盘和微云了,不过由于没有百度网盘搜索引擎入口,云盘用户只能看到自己的软件。华军为大家准备了一款百度云盘搜索工具,可以搜索别人分享的资源。百度网盘怎么用?百度网盘客户端怎么用?现在注册百度云盘只支持手机号,并且6月1日之后必须实名制,否则不能使用。如果想下载资源,需先保存到自己的云盘,然后使用百度网盘...
联通下载地址
电信下载地址
移动及其他下载地址
(您的评论需要经过审核才能显示)
找了那么多下载软件网站下载百度通地图定位,终于让我找到你了,我的百度通地图定位1.8.6
这个百度通地图定位好用么,相比上个版本变化大不大,我看安装包大小都已经这么大了了
地图导航软件我只认百度通地图定位,功能强大不说,百度通地图定位1.8.6软件才2.66M。
我觉得百度通地图定位这款软件很不错,支持华军软件园,希望越做越好!
很好用哈哈,最喜欢这个百度通地图定位了,别的都不怎么样。。
感觉还不错,百度通地图定位1.8.6比上个版本要好的多
已经下载安装成功了,这种国产软件大多都挺很好用的
百度通地图定位帮我了很大忙,感谢华军软件园
讲真,地图导航里我只服百度通地图定位,不解释
百度通地图定位有没有破解版的啊,有的朋友麻烦推荐一下
本类下载排行
其他用户还推荐了的软件
手机软件最新更新
高清手机壁纸推荐
热门关键词}

我要回帖

更多关于 百度地图定位自己位置 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信