mLocClient.stop(); // mBaiduMap.setMyLocationEnabled(false); // LatLng ll = new LatLng(Double.parseDouble(poi_wei),Double.parseDouble(poi_jing)); //// LatLng lll = new LatLng() // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); // llposition = ll; // city = location.getCity(); // district = location.getDistrict(); // initOverlay(); // } MobclickAgent.onResume(this); } @Override protected void onDestroy() { Bimp.tempSelectBitmap.clear(); Bimp.max = 0; mapView.onDestroy(); // mMapView = null; super.onDestroy(); // bdLocation.recycle(); } private static String getPath(String path) { File f = new File(path); if (!f.exists()) { f.mkdirs(); } return f.getAbsolutePath(); } private File getFile(String path) { File f = new File(path); if (!f.exists()) { try { f.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } return f; } public Bitmap decodeUriAsBitmap(Uri uri) { Bitmap bitmap = null; try { bitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri)); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } return bitmap; } private Bitmap imageZoom(Bitmap bm) { // 图片允许最大空间 单位:KB double maxSize = 200.00; // 将bitmap放至数组中,意在bitmap的大小(与实际读取的原文件要大) ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b = baos.toByteArray(); // 将字节换成KB double mid = b.length / 1024; // 判断bitmap占用空间是否大于允许最大空间 如果大于则压缩 小于则不压缩 if (mid > maxSize) { // 获取bitmap大小 是允许最大大小的多少倍 double i = mid / maxSize; // 开始压缩 此处用到平方根 将宽带和高度压缩掉对应的平方根倍 // (1.保持刻度和高度和原bitmap比率一致,压缩后也达到了最大大小占用空间的大小) bm = zoomImage(bm, bm.getWidth() / Math.sqrt(i), bm.getHeight() / Math.sqrt(i)); } return bm; } public Bitmap zoomImage(Bitmap bgimage, double newWidth, double newHeight) { // 获取这个图片的宽和高 float width = bgimage.getWidth(); float height = bgimage.getHeight(); // 创建操作图片用的matrix对象 Matrix matrix = new Matrix(); // 计算宽高缩放率 float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // 缩放图片动作 matrix.postScale(scaleWidth, scaleHeight); Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, (int) height, matrix, true); // iv_2.setImageBitmap(bitmap); // tv_2.setText(bitmap.getRowBytes() * bitmap.getHeight() + ""); return bitmap; } //地图缩放方法 private void controlZoomShow() { float zoom = aMap.getCameraPosition().zoom; try { if (zoom >= maxZoomLevel) { inBtn.setImageResource(R.drawable.icon_nojia2_0); inBtn.setEnabled(false); // Toast.makeText(getApplication(), "已放大到最大级别", Toast.LENGTH_SHORT) // .show(); return; } else { inBtn.setImageResource(R.drawable.icon_jia2_0); inBtn.setEnabled(true); } if (zoom <= minZoomLevel) { outBtn.setImageResource(R.drawable.icon_nojian2_0); outBtn.setEnabled(false); // Toast.makeText(getApplication(), "已缩小到最小级别", Toast.LENGTH_SHORT) // .show(); return; } else { outBtn.setImageResource(R.drawable.icon_jian2_0); outBtn.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); } } private void initMap() { if (aMap == null) { aMap = mapView.getMap(); Util.setMapCustomStyleFile(aMap, getApplicationContext()); // View v = mapView.getChildAt(0); // v.setOnTouchListener(new View.OnTouchListener() { // // @Override // public boolean onTouch(View v, MotionEvent event) { // if(event.getAction() == MotionEvent.ACTION_SCROLL){ // scrollView.requestDisallowInterceptTouchEvent(false); // }else{ // scrollView.requestDisallowInterceptTouchEvent(true); // } // return false; // } // }); MyLocationStyle myLocationStyle = new MyLocationStyle(); myLocationStyle.myLocationIcon(BitmapDescriptorFactory .fromResource(R.drawable.point_icon));// 设置小蓝点的图标 aMap.setMyLocationStyle(myLocationStyle); mUiSettings = aMap.getUiSettings(); //获得地图的最大和最小缩放级别 maxZoomLevel = aMap.getMaxZoomLevel(); minZoomLevel = aMap.getMinZoomLevel(); try { geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); setUpMap(); } catch (AMapException e) { e.printStackTrace(); } } } private void setUpMap() { aMap.setOnCameraChangeListener(this); aMap.setLocationSource(this);// 设置定位监听 aMap.setOnMapLoadedListener(this); aMap.setInfoWindowAdapter(this); aMap.setOnMapClickListener(this); aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示 aMap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示 aMap.getUiSettings().setScaleControlsEnabled(true);// 设置比例尺是否显示 aMap.getUiSettings().setRotateGesturesEnabled(false);// 设置地图是否旋转 aMap.setOnMapTouchListener(this); } @Override public void onCameraChange(CameraPosition cameraPosition) { } @Override public void onCameraChangeFinish(CameraPosition cameraPosition) { } @Override public void activate(OnLocationChangedListener onLocationChangedListener) { mListener = onLocationChangedListener; if (mlocationClient == null) { try { mlocationClient = new AMapLocationClient(this); mLocationOption = new AMapLocationClientOption(); //设置定位监听 mlocationClient.setLocationListener(this); //设置为高精度定位模式 mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //设置定位参数 mlocationClient.setLocationOption(mLocationOption); // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗, // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求 // 在定位结束后,在合适的生命周期调用onDestroy()方法 // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除 // 设置是否只定位一次,默认为false mLocationOption.setOnceLocation(true); //设置是否强制刷新WIFI,默认为强制刷新 mLocationOption.setWifiActiveScan(false); mlocationClient.startLocation(); } catch (Exception e) { e.printStackTrace(); } } } @Override public void deactivate() { mListener = null; if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient = null; } private void getGaode(Double jing, Double wei) { // Log.e("jing", jing + ""); // Log.e("wei", wei + ""); double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double gg_lon; double gg_lat; double x = jing - 0.0065, y = wei - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); gg_lon = z * Math.cos(theta); gd_jing = String.valueOf(gg_lon); // Log.e("gg_lon", gg_lon + ""); gg_lat = z * Math.sin(theta); gd_wei = String.valueOf(gg_lat); // Log.e("gg_lat", gg_lat + ""); } @Override public void onMapLoaded() { aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种 aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); // aMap.moveCamera(); aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); getGaode(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei)); LatLng ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); // LatLng lll = new LatLng() // MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); // mBaiduMap.animateMapStatus(u); llposition = ll; //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(llposition)); initOverlay(); } @Override public void onRegeocodeSearched(RegeocodeResult result, int i) { if (i == 1000) { if (result != null && result.getRegeocodeAddress() != null && result.getRegeocodeAddress().getFormatAddress() != null) { et_share_address.setText(result.getRegeocodeAddress().getFormatAddress()); // tv_submit.setBackgroundColor(getResources().getColor(R.color.lvse)); } } } @Override public void onGeocodeSearched(GeocodeResult geocodeResult, int i) { } @Override public void onMapClick(LatLng latLng) { isTouch = true; llposition = latLng; Log.e("jing", llposition.longitude + ""); Log.e("wei", llposition.latitude + ""); // initOverlay1(); // getAddress(); } @Override public void onLocationChanged(AMapLocation amapLocation) { // if (mListener != null && amapLocation != null) { if (amapLocation != null && amapLocation.getErrorCode() == 0) { try { // tv_addressName.setText(amapLocation.getAddress()); // poi_jing = String.valueOf(amapLocation.getLongitude()); // poi_wei = String.valueOf(amapLocation.getLatitude()); } catch (NullPointerException e) { e.printStackTrace(); } // ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity); if (!isFirstLoc) { center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()); // Log.e("!@#$",amapLocation.getLatitude()+"```"+amapLocation.getLongitude()); //// Toast.makeText(this, amapLocation.getAddress(), Toast.LENGTH_SHORT).show(); //// Toast.makeText(this, amapLocation.getCity(), Toast.LENGTH_SHORT).show(); // ete("{\"fun\":\"timer\"}"); //设置缩放级别 aMap.moveCamera(CameraUpdateFactory.zoomTo(16)); //将地图移动到定位点 aMap.moveCamera(CameraUpdateFactory.changeLatLng(center)); //点击定位按钮 能够将地图的中心移动到定位点 mListener.onLocationChanged(amapLocation); } isFirstLoc = false; } else { String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo(); Log.e("AmapErr", errText); // mLocationErrText.setVisibility(View.VISIBLE); Toast.makeText(this, errText, Toast.LENGTH_SHORT).show(); } } } schmerzmittel-kaufen9933/helaine1981 - Gogs: Go Git Service

Этот репозиторий пуст, пожалуйста, возвращайтесь позже!