android - 街景在 android 应用程序中显示错误消息

标签 android google-maps android-studio kotlin google-street-view

嗨,我正在研究谷歌地图。我已经在 fragment 中添加了位置,现在正在尝试将 StreetViewPanoramaView 添加到 fragment 中。但是我越来越糟糕了!出现问题的错误消息,如第二张图片所示
这是我的代码

maps_activity.xml

 <Button
    android:id="@+id/button_streetview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Open StreetView"
    />

<androidx.fragment.app.FragmentContainerView
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MapsActivity" />

<com.google.android.gms.maps.StreetViewPanoramaView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/streetview"/>

这是我的 MapActivity.kt
 button_streetview.setOnClickListener(View.OnClickListener {


     var mStreetViewPanoramaView : StreetViewPanoramaView = findViewById(R.id.streetview)
        mStreetViewPanoramaView.onCreate(savedInstanceState)



        var streetViewPanorama: StreetViewPanoramaOptions = StreetViewPanoramaOptions()
        streetViewPanorama.panningGesturesEnabled(false)
        streetViewPanorama.position(address)
        streetViewPanorama.userNavigationEnabled(false)
        streetViewPanorama.zoomGesturesEnabled(true)

        var streetViewPanoramaCamera : StreetViewPanoramaCamera = StreetViewPanoramaCamera(25F,30F,1F)
        streetViewPanorama.panoramaCamera(streetViewPanoramaCamera)
        mStreetViewPanoramaView = StreetViewPanoramaView(this,streetViewPanorama)
        mStreetViewPanoramaView.getStreetViewPanoramaAsync(this)
    })

我可以通过地址成功检索一个地方的纬度和经度,并将其显示在 infoWindow 中并添加自定义标记,如图所示。
但是当我单击openstreetview 按钮时,错误消息就来了。 enter image description here

这是街景
enter image description here

这是日志猫
enter image description here

由于此错误消息显示错误的 API key ,但我添加了正确的 key ,因为我可以成功检索并显示标记。谁能告诉我哪里做错了

最佳答案

您似乎收到了所描述的错误 here :

If you receive an error such as Your card does not support automatic recurring payments or General decline of the card, please select a different form of payment.

You might encounter these errors if you are using a debit card that requires two-factor authentication to complete an online transaction.

Two-factor authentication requires you to be in-session at the time of the transaction. Cards that require you to be in-session are not usable for subscriptions or similar recurring automatic transactions.



启用项目计费后,您的街景 map 应该可以正常工作。希望这可以帮助!

关于android - 街景在 android 应用程序中显示错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60321542/

相关文章:

java - Android 自定义 AutoCompleteTextView 与自定义适配器

java - 使用 Mockito 对 SharedPreferences 包装器进行单元测试

javascript - 是否可以在某些条件下关闭信息窗口

android - 有什么方法可以使用 Google Places API 获取某个地方的时间 "people typically spend"吗?

android - 从 Android 访问 Google map 中的 "My Maps"

android - 我是否应该将用作 Android Bundle 内键的字符串作为资源存储?

android - 如何读取android xml文件中的属性文件值

android - 如何在 Android Studio Dolphin 中切换到旧的 LogCat

java - map 上的标记 - 尝试在空对象引用上调用虚拟方法

android-studio - 库使用与该项目相同的包