Mostrar MapFragment en un DialogFragment
Soy nuevo con el desarrollo de Android y estoy trabajando en una aplicación donde necesito utilizar google mapa para seleccionar la posición del evento y tengo que mostrar este mapa como un popup de windows, veo este post:
MapFragment en DialogFragment
- Google Map v2 dentro del fragmento android
- Google map se estrella en pocos dispositivos
- SupportMapFragment en DialogFragment
- MapFragment.getMap () devuelve null
- Cambiar de fragmento con fragmento de mapa deja una pantalla negra
Tengo el mismo problema enumerado en el poste pero no entendí cómo hacer esto
ella es lo que hice:
Diseño XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".AddEventActivity" > <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" > <LinearLayout android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="15dp" > <TextView android:id="@+id/textView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Address :" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:id="@+id/map_button" android:layout_width="45dp" android:layout_height="45dp" android:adjustViewBounds="false" android:padding="3dp" android:scaleType="centerInside" android:src="@drawable/map_icon" /> <EditText android:id="@+id/adress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:ems="10" > </EditText> </LinearLayout> <FrameLayout android:id="@+android:id/realtabcontent" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="280dp" class="com.google.android.gms.maps.SupportMapFragment" /> </FrameLayout> </LinearLayout> </ScrollView>
en el botón de clic:
map_butt.setOnClickListener(new View.OnClickListener() { @SuppressLint("NewApi") @Override public void onClick(View v) { // TODO Auto-generated method stub Window window = getWindow(); window.setFlags( WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); WindowManager.LayoutParams wmlp = window.getAttributes(); wmlp.y -= 10; window.setAttributes(wmlp); gm = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); marker = gm.addMarker(new MarkerOptions().title("Vous êtes ici").position(new LatLng(0, 0))); } });
Gracias por cualquier ayuda
- Estado de error: active SupportMapFragment {} ha borrado el índice: -1
- Referencia MapView en SupportMapFragment
- SupportMapFragment y onMapReady
- Cómo utilizar SupportMapFragment dentro de un fragmento?
- GetMapAsync () en el fragmento
- ClassNotFoundException leyendo un objeto Serializable en una clase que extiende MapFragment en onSaveInstanceState
- Google Maps Android API v2 detecta un clic largo en el mapa y agrega marcador que no funciona
- No se puede cambiar el identificador de contenedor del fragmento SupportMapFragment