开发者

Does anyone know why my Maps aren't showing up in my app?

I am using a debugging key for my API. I have generated it about 10 times now out of desperation.

Here's my Java code:

public class MyMap extends MapActivity {

private MapView mapView;
private MapController mc;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.my_map);

    mapView = (MapView) findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
    }
}

Here's the XML layout file:

<com.google.android.maps.MapView
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:apiKey="0UsP9tzCZAIzw2b76-QktRuiZKaDt59u6ySX09w" android:id="@+id/mapView"
    android:clickable="true" android:enabled="true" />

</LinearLayout>

And here's my manifest file:

<application android:icon="开发者_运维技巧@drawable/icon" android:label="@string/app_name" android:debuggable="true">

    <activity android:name=".MyMap" android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar"
        android:screenOrientation="portrait">

        <intent-filter>

            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />

        </intent-filter>

    <uses-library android:name="com.google.android.maps" />

</application>

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-sdk android:minSdkVersion="1" />

I just keep getting the grid. I haven't got a clue why. I have been at this for hours now. Also, I have done this with a release key, made an APK and still the same problem.

Can anyone help?

SOLVED:

I had my MapActivity inside an ActivityGroup and for some reason the maps won't load like that. I simply took the map out of the ActivityGroup, loaded it as it's own Intent and it worked fine. Weird problem. Google should get on sorting that out.


I think you also have to implement this method to conform to the use of the maps API:

@Override
protected boolean isRouteDisplayed()
{       
    return false;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜