Jump to content

Dificuldade Maps API em Fragment - Android Studio


Psycop
 Share

Recommended Posts

Boa tarde

Estou a tentar incluir a api Maps dentro de um fragmento com o objectivo de representar a localização de um edifício, no entanto todas as tentativas tem resultado no crash do respectivo fragmento (view) quando esta é chamada.

O código xml é o seguinte:

<fragment
			android:id="@+id/map"
			class="com.google.android.gms.maps.SupportMapFragment"
			android:layout_width="300dp"
			android:layout_height="300dp"
			android:layout_centerHorizontal="true"
			android:layout_below="@+id/textView_5"
			android:layout_marginTop="25dp" />

No java do fragmento tenho o seguinte:


    View rootview;

//Variavel das Coordenadas
static final LatLng CERTIC = new LatLng(41.287138, -7.740733);
private GoogleMap map;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	rootview = inflater.inflate(R.layout.menu_contactos_layout, container, false);

	//Mapa
	map = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMap();

	//Marker posição CERTIC no Mapa
	Marker certic = map.addMarker(new MarkerOptions().position(CERTIC).title("CERTIC"));

Tenho a key correctamente gerada, e a API Google Play Services está instalada no Android Studio.

Não consigo perceber o porque, se alguém me conseguir ajudar agradecia.

Edited by Psycop
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.