gpt4 book ai didi

java - 如何在android mapview中显示 map

转载 作者:搜寻专家 更新时间:2023-11-01 08:04:04 24 4
gpt4 key购买 nike

enter image description here

我在 android mapview 中创建了 google map 。但是在 mapview.iam 中使用自己的 google mapview API key 显示灰度。

如何在没有灰度的mapview中获取 map ?

public class MainActivity extends MapActivity {

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}


}


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:apiKey="AIzaSyBNpjyktHItZYm4no0wTvzSv8tWU5gaoy0" />

</RelativeLayout>

这是我的代码,它的显示灰度。如何解决?

http://wptrafficanalyzer.in/blog/showing-current-location-using-onmylocationchangelistener-in-google-map-android-api-v2/我引用此链接但显示空白输出 enter image description here

最佳答案

首先,正如 CommonsWare 所说,您应该使用 v2 map API。你什么时候申请 key 的? 2013 年 3 月之后,您无法请求 Maps v1 key 。我怀疑您可能正在尝试将 v2 key 与 v1 API 一起使用。检查您的 logcat 以查看是否有消息。

参见 Google Maps API (v2)

另一种可能是您错误地注册了 key 。你确定你有正确 key 的 SHA1 指纹吗?如果您在可用时注册了 v1 key ,您确定要使用注册的同一 key 进行签名吗?

此外 - 根据您的状态栏,您似乎没有获得良好的连接。 Google map 需要网络连接。尝试打开 wifi 以检查它是否有效。如果是这样,您可能只是没有下载 map 。如果 wifi 工作,请尝试让应用程序在 wifi 关闭的情况下静置一会儿,看看 map 是否最终加载超过 3G。

关于java - 如何在android mapview中显示 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16836520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com