简体   繁体   English

切片不会通过地图视图加载,但会加载片段

[英]Tiles wont load with Map view but loads with fragment

i am trying to run this really simple app on my device (with maps API V2) and for some reason when trying to use MapView: 我试图在我的设备上运行这个非常简单的应用程序(使用Maps API V2),并且由于某些原因尝试使用MapView时运行该应用程序:

<com.google.android.maps.MapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="(i did put the correct key)"
android:id="@+id/mvMap"/>

with the java file: 与java文件:

 public class MainMap extends MapActivity  {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_layout);
}
@Override
protected boolean isRouteDisplayed() {

    return false;
}

the tiles will not load!! 瓷砖将无法加载! but when I'm using a fragment: fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 但是当我使用片段时:fragment android:id =“ @ + id / map” android:name =“ com.google.android.gms.maps.SupportMapFragment” android:layout_width =“ fill_parent” android:layout_height =“ fill_parent“ />

with - extends FragmentActivity in java file it works perfectly fine... 使用-在Java文件中扩展FragmentActivity,效果非常好...

what is going on??? 到底是怎么回事???

Please read this very good tutorial on how to implement GoogleMaps in Android: http://www.vogella.com/tutorials/AndroidGoogleMaps/article.html 请阅读有关如何在Android中实现GoogleMaps的很好的教程http : //www.vogella.com/tutorials/AndroidGoogleMaps/article.html

Without you posting any error message , there could be dozens of reasons why your map is not showing. 如果您未发布任何错误消息 ,则可能有多种原因导致您的地图不显示。

The following are the most common misstakes: 以下是最常见的错误

  • Forgot to set certain permissions 忘记设置某些权限
  • API key not obtained correctly 无法正确获取API密钥
  • No Internet connection 没有网络连接
  • GooglePlayServices not up to date on your device GooglePlayServices在您的设备上不是最新的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM