有谁知道为什么我的地图没有显示在我的应用程序中?
我正在为我的 API 使用调试密钥。出于绝望,我现在已经生成了大约 10 次。
这是我的 Java 代码:
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);
}
}
这是 XML 布局文件:
<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>
这是我的清单文件:
<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" />
我只是不断地获取网格。我不知道为什么。我已经在这几个小时了。另外,我已经使用发布密钥完成了此操作,制作了 APK,但仍然存在同样的问题。
有人可以帮忙吗?
已解决:
我将 MapActivity 放在 ActivityGroup 中,由于某种原因,地图不会像那样加载。我只是将地图从 ActivityGroup 中取出,将其作为它自己的 Intent 加载,并且工作正常。奇怪的问题。谷歌应该着手解决这个问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您还必须实现此方法以符合地图 API 的使用:
I think you also have to implement this method to conform to the use of the maps API: