java - 谷歌地图标记显示在安卓设备上,但不在模拟器上
问题描述
尝试在 android studio 中向谷歌地图片段添加标记。当代码在 android 设备上运行时,代码运行成功,在地图上显示标记,但是当尝试在模拟器上运行时,标记永远不会显示
marker = mMap.addMarker(new MarkerOptions()
.position(new LatLng(point.getLat(), point.getLongi()))
.title("Point: " +point.getID())
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN))
);
marker.setSnippet("Latitude: " + point.getLat() + "\nLongitude: " + point.getLongi() + "\nDescription: " + point.getDesc() + "\nLight at " + point.getTime() + " : " + point.getLight());
marker.setTag(point.getID());
markers.add(marker);
marker.setVisible(true);
预期:标记显示在地图上实际:没有标记显示
出于某种原因,此标记确实显示:
mMap.addMarker(new MarkerOptions()
.position(new LatLng(10, 10))
.title("Hello world"));
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/include"
layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
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="382dp"
map:layout_anchor="@+id/include"
map:layout_anchorGravity="bottom|center"
tools:context=".MapsActivity" />
</android.support.design.widget.CoordinatorLayout>
已修复,我将把它作为我羞耻的证明,标记在地图上,但模拟器设置为 N. America。在我的愚蠢中,我没有缩小并看到这个,它从一开始就没有被打破
解决方案
推荐阅读
- python - 如何使用具有 5 个估计器的 VotingClassifier,但为每个估计器使用不同的(并且已经创建的)训练子集?
- java - Sonarqube 任务不使用 Android 项目执行测试,而是使用 Java 项目执行
- stripe-payments - 配置 Omnipay Stripe SCA 3D
- python - 在特定列的 Pandas 数据框中插入一行(没有名称)
- c - 在 C 中使用链表实现队列
- json - Swagger 定义解析为简化的 JS 对象(复杂对象操作)
- django - Django:计算平均食谱评分
- c# - 通过 asp.net core 设置本地存储
- php - Laravel 在控制器构造函数中从数据库中获取应用程序常量
- docker - 我在哪里可以找到 github 操作与预安装软件一起使用的 docker 映像