百度地图android定位开发,Android百度地图开发(二)定位之手动定位

直接上代码:

布局文件如下:

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:id="@+id/bmapView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:clickable="true" />

android:id="@+id/fire_map_ib"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentTop="true"

android:layout_alignParentRight="true"

android:layout_margin="10dp"

android:background="@null"

android:src="@drawable/ic_myloc_btn_black" />

相关class代码如下:

/**

* 点击定位并将位置移动到屏幕中间

*/

imageButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

mLocationClient.requestLocation();

LatLng point = new LatLng(

MyApplication.LOC_LAT, MyApplication.LOC_LON);

MapStatusUpdate u = MapStatusUpdateFactory

.newLatLng(point);

/*u = MapStatusUpdateFactory.newLatLngZoom(point,

mBaiduMap.getMaxZoomLevel());*/

mBaiduMap.animateMapStatus(u);

mBaiduMap.setMapStatus(u);

Toast.makeText(getActivity(), "定位中……", Toast.LENGTH_SHORT).show();

}

});

请自行整合之前代码,如有疑问,欢迎留言讨论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值