benim layout'ta MapView ile bu sorunu ettik tamamen sonra göstermektedir. Görünür hale getirmek için ekranı kapatıp açmam gerekiyor. Sorun ne? İşteMapView ekran açıldığında tekrar
kodum
mapView = (MapView) geo.findViewById(R.id.map_view);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
final LocationManager lm = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
lastKnownLocation = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(lastKnownLocation == null) {
askLocationRefreshInitMapView(lm);
} else {
if((System.currentTimeMillis() - lastKnownLocation.getTime()) > THIRTY_MINUTES) {
askLocationRefreshInitMapView(lm);
} else {
initMapView(lastKnownLocation);
}
}
private void initMapView(final Location location) {
lastKnownLocation = location;
// Gets to GoogleMap from the MapView and does initialization stuff
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
try {
MapsInitializer.initialize(getActivity());
} catch (Exception e) {
e.printStackTrace();
}
// Updates the location and zoom of the MapView
if(location != null) {
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 10);
map.moveCamera(cameraUpdate);
map.animateCamera(cameraUpdate);
}
map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
});
}
Bunu yaptım ama parçam üzerine onMapReady koyup önerilen hiçbir şey göstermiyor. En azından bir ızgara göstermeden önce. Bu yüzden mapView.onResume(); onMapReady yönteminin son instrunction olarak ve şimdi harita görüntüler ... ama çok garip ve neden olduğunu anlayamıyorum ... – tassadar
Haritanın içine yerleştirmeye çalıştım yerine xml parçasını yerleştirmek yerine dinamik ve çalışır. Yani sorun, çalışma zamanında yeni bir düzeni şişirmek ve onu parça düzenine eklemekle ilgili gibi görünüyor. Birisi dinamik olarak şişirilmiş bir yaklaşımla çalışmama yardım edebilir mi? – tassadar
@tassadar SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager(). FindFragmentById (R.id.where_are_they_map); mapFragment.getMapAsync (this); –