街景视图在 android 应用中显示错误消息
Street view is showing error message in android app
您好,我正在制作 google 地图。我已经在片段中添加了位置,现在正在尝试将 StreetViewPanoramaView 添加到片段中。但是我越来越糟糕了!出现错误错误消息,如第二张图片所示
这是我的代码
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)
})
我可以通过地址成功检索地点的纬度和经度并将其显示在信息窗口中并添加自定义标记,如图所示。
但是当我点击 openstreetview 按钮时出现错误消息。
这是街景
这是logcat
因为此错误消息显示错误的 API 键,但我添加了正确的键,因为我可以成功检索和显示标记。谁能告诉我哪里做错了
您似乎遇到了描述的错误 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.
在您的项目上启用计费功能后,您的街景地图应该可以正常使用。希望这对您有所帮助!
您好,我正在制作 google 地图。我已经在片段中添加了位置,现在正在尝试将 StreetViewPanoramaView 添加到片段中。但是我越来越糟糕了!出现错误错误消息,如第二张图片所示 这是我的代码
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)
})
我可以通过地址成功检索地点的纬度和经度并将其显示在信息窗口中并添加自定义标记,如图所示。
但是当我点击 openstreetview 按钮时出现错误消息。
这是街景
这是logcat
因为此错误消息显示错误的 API 键,但我添加了正确的键,因为我可以成功检索和显示标记。谁能告诉我哪里做错了
您似乎遇到了描述的错误 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.
在您的项目上启用计费功能后,您的街景地图应该可以正常使用。希望这对您有所帮助!