谁能帮助我让这个地图应用程序正常运行?
问题是我的地图没有显示。这只是当您(例如:)没有获得互联网权限时显示的网格。
这是我的 java 类:
public class MapClass extends MapActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.maplayout);
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
这是我的 XML 布局文件(减去映射键):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView" android:layout_width="fill_parent"
android:enabled="true" android:layout_height="fill_parent"
android:clickable="true" android:apiKey="MY-API-KEY" />
</RelativeLayout>
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.mapexample" android:versionCode="1"
android:versionName="1.0" android:installLocation="internalOnly">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapClass" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>>
</activity>
</application>
<uses-sdk android:minSdkVersion="1" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</manifest>
The problem is that my map isn't showing. It's just the grid that shows when you (for example:) haven't got the INTERNET permission.
Here's my java class:
public class MapClass extends MapActivity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.maplayout);
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Here's my XML Layout file (minus the Map Key):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView" android:layout_width="fill_parent"
android:enabled="true" android:layout_height="fill_parent"
android:clickable="true" android:apiKey="MY-API-KEY" />
</RelativeLayout>
And here's my Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.mapexample" android:versionCode="1"
android:versionName="1.0" android:installLocation="internalOnly">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapClass" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>>
</activity>
</application>
<uses-sdk android:minSdkVersion="1" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您的应用程序使用与您的地图 API 密钥关联的签名密钥进行签名。我怀疑您正在调试,因此该应用程序是使用调试密钥库进行签名的...您必须为此生成一个不同的 Map API 密钥。
我保留 2 个布局,每个布局对应一个 Map API 密钥。我根据是否在调试版本或发布版本中运行来动态选择布局。
Make sure your app is signed with the signing key you associated with your Map API key. I suspect you are debugging, so the app is signed with the debug keystore...you have to generate a different Map API key for that.
I keep 2 layouts, one for each Map API key. I dynamically choose my layout based on whether I am running in a debug or release build.