本文主要是介绍Android高德地图添加范围覆盖物显示当前位置覆盖物,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*** 获取当前位置经纬度一次*/
private void getLocationInfo() {LocationUtils.getInstance().getLocation(new LocationUtils.OnLocationChangedListener() {@Overridepublic void onSuccess(double latitude, double longitude, String addressstr) {// ToastUtils.showLongToast(mCtx, latitude + "====" + longitude + "====" + addressstr);lat = latitude;lng = longitude;// 当前定位成功之后再去请求订单数据LatLng location = new LatLng(latitude, longitude);aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 16));// 绘制一个圆形/*circle = aMap.addCircle(new CircleOptions().center(location).radius(200).fillColor(Color.argb(22, 1, 1, 1)).strokeColor(Color.argb(22, 1, 1, 1)).strokeWidth(1));*/// 添加infoWindowaMap.setInfoWindowAdapter(new AMap.InfoWindowAdapter() {@Overridepublic View getInfoWindow(Marker marker) {View infoWindow = getLayoutInflater().inflate(R.layout.map_info_window, null);TextView tv_info = (TextView) infoWindow.findViewById(R.id.tv_info);LinearLayout ll_left_time = (LinearLayout) infoWindow.findViewById(R.id.ll_left_time);TextView tv_left_time = (TextView) infoWindow.findViewById(R.id.tv_left_time);// tv_info.setText("");return infoWindow;}@Overridepublic View getInfoContents(Marker marker) {return null;}});// 添加当前坐标覆盖物markerOption = new MarkerOptions().icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_location_point))).position(location).draggable(true);Marker marker = aMap.addMarker(markerOption);marker.showInfoWindow();}@Overridepublic void onFail(int errCode, String errInfo) {AppUtil.showToast(errCode + "====" + errInfo);}});
}
这篇关于Android高德地图添加范围覆盖物显示当前位置覆盖物的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!