MapFragment problems. This is all in white, and I can not make it display a map (ANDROID)



First of all, sorry for my English. The problem is I can not display a map in MapFrament. Seek help tutorials, and I could not fix it. I'm using the ADT adroind. I could get my key in GoogleDeveloperConsole. The problem is that when I run it explodes.


when you put these lines in the Manifest.xml not explode, but shows me the blank MapFragment:



<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


I tried with all I had at my disposal, I need help. I leave my code.


Manifest.xml:



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.example.mapa"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />

<permission
android:name="com.example.googlemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.android.mapexample.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY KEY" />
</application>

</manifest>


Activity.java:



package com.example.android.mapexample;
import com.example.mapa.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.support.v7.app.ActionBarActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity
{

static final LatLng TutorialsPoint = new LatLng(21 , 57);
private GoogleMap googleMap;

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
if (googleMap == null) {
googleMap `=((MapFragment)getFragmentManager().findFragmentById(R.id.mapa)).getMap();`
}
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
Marker TP = googleMap.addMarker(new MarkerOptions().
position(TutorialsPoint).title("TutorialsPoint"));

} catch (Exception e) {
e.printStackTrace();
}

}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings)
{
return true;
}
return super.onOptionsItemSelected(item);
}}


activity.xml



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.mapexample.MainActivity" >

<fragment
android:id="@+id/mapa"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="matcenter code hereh_parent"
android:layout_height="match_parent"/>

</RelativeLayout>


in theory the library was loaded successfully the project.


Could someone help me? please


Greetings


No comments:

Post a Comment