大佬教程收集整理的这篇文章主要介绍了android – map.setmylocationenabled(true)不工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
按钮单击侦听器:
@H_753_2@mMap.setOnMyLOCATIOnButtonClickListener(new GoogleMap.onMyLOCATIOnButtonClickListener() { @Override public Boolean onMyLOCATIOnButtonClick() { mMap.addMarker(new MarkerOptions().position(myLatLng).title("My LOCATIOn")); mMap.animateCamera(CameraupdateFactory.newLatLngZoom(myLatLng,zoomLevel)); return false; } });然后onLOCATIOnChanged()中的代码将重新定位摄像机位置,然后再次注册位置更新:
@Override public void onLOCATIOnChanged(LOCATIOn LOCATIOn) { mLastLOCATIOn = LOCATIOn; if (mCurrLOCATIOnMarker != null) { mCurrLOCATIOnMarker.remove(); } //Place current LOCATIOn marker LatLng latLng = new LatLng(LOCATIOn.getLatitude(),LOCATIOn.getLongitude()); MarkerOptions markerOptions = new MarkerOptions(); markerOptions.position(latLng); markerOptions.title("Current Position"); markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA)); mCurrLOCATIOnMarker = mGoogleMap.addMarker(markerOptions); //move map camera mGoogleMap.moveCamera(CameraupdateFactory.newLatLng(latLng)); mGoogleMap.animateCamera(CameraupdateFactory.zoomTo(11)); if (mGoogleApiClient != null) { LOCATIOnservices.FusedLOCATIOnApi.removeLOCATIOnupdates(mGoogleApiClient,this); } }
以上是大佬教程为你收集整理的android – map.setmylocationenabled(true)不工作全部内容,希望文章能够帮你解决android – map.setmylocationenabled(true)不工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。