這裏移動是我的代碼:谷歌地圖我得到當前的位置當我改變位置標記不會在谷歌地圖
public class MapViewFragment extends Fragment implements OnMapReadyCallback {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.maps, container, false);
Context context =this.getContext();
GPSService mGPSService = new GPSService(context);
mGPSService.getLocation();
if (mGPSService.isLocationAvailable == false) {
} else {
// Getting location co-ordinates
lat1 = mGPSService.getLatitude();
lng1 = mGPSService.getLongitude();
}
mMapView.onCreate(savedInstanceState);
ActivityCompat.requestPermissions(getActivity(),new String[]{
android.Manifest.permission.ACCESS_FINE_LOCATION}, 1);
call.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
call();
}
});
mMapView.getMapAsync(this); //this is important
}
});*/
}
return v;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mGoogleMap = googleMap;
mGoogleMap.getUiSettings().setZoomControlsEnabled(true);
m1 = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(lat1,lng1))
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.anchor(0.5f, 0.5f)
.title("Title1")
.snippet("Snippet1"));
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
}
在節目我獲取當前位置經緯度和lang.When我移到其他位置標記不會改變。每當我移動的位置不得不改變。 當前位置值iam每當我移動位置值時都不會改變。要實現任何方法改變位置。
移動到你的意思是你真正移動,並期待在位置其他位置?或者你的意思是用mapview移動到其他位置? –
我可以從代碼中獲取當前位置。如何在谷歌地圖上連續移動標記與谷歌默認當前位置標記相同android – Jayapriya
感謝您的回覆 – Jayapriya