高德地图通过Demo中的小篮点定位后地图比例都很小,想看多一些的地方只能通过手动点击进行选择,但在选择的时候可以通过定位+marker的模式定位 并设置比例大小
定位实现可看高德官方文档http://lbs.amap.com/api/android-location-sdk/locationsummary/
设置地图比例 添加中心点
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 13));// 通过定位后获得的经纬度 为地图添加中心点 和地图比例 数字越小地图显示越多
public AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation amapLocation) {
// TODO Auto-generated method stub
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
amapLocation.getLatitude();//获取纬度
amapLocation.getLongitude();//获取经度
amapLocation.getAccuracy();//获取精度信息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(amapLocation.getTime());
df.format(date);//定位时间
amapLocation.getAddress();//地址,如果option中设置isNeedAddress为false,则没有此结果,网络定位结果中会有地址信息,GPS定位不返回地址信息。
amapLocation.getCountry();//国家信息
amapLocation.getProvince();//省信息
amapLocation.getCity();//城市信息
amapLocation.getDistrict();//城区信息
amapLocation.getStreet();//街道信息
amapLocation.getStreetNum();//街道门牌号信息
amapLocation.getCityCode();//城市编码
amapLocation.getAdCode();//地区编码
lat = amapLocation.getLatitude();//获取纬度
lng =amapLocation.getLongitude();//获取经度
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lng), 13));// 通过定位后获得的经纬度 为地图添加中心点 和地图比例 数字越小地图显示越多
Marker marker;
markerOption = new MarkerOptions().icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.position(new LatLng(lat,lng))
.draggable(true)
.title("当前位置")
.snippet("太原市万立科技大厦")
.draggable(true);
marker = aMap.addMarker(markerOption);
marker.showInfoWindow();
mLocationClient.stopLocation();//停止定位
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Log.e("info","location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
};