首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓googleMap -如何在没有工具提示箭头的情况下添加InfoWindow

问安卓googleMap -如何在没有工具提示箭头的情况下添加InfoWindow
EN

Stack Overflow用户
提问于 2019-07-03 11:25:01
回答 2查看 371关注 0票数 1

​

​

我正在搜索这样一个没有工具提示箭头的文本框。当我查看android google地图功能时,它看起来是这样的:

sample googleMap snippet, notice the arrow

我该如何隐藏箭头呢?这些都是定制的吗?

EN

回答 2

Stack Overflow用户

发布于 2019-07-12 18:19:36

使用谷歌地图util库中的iconGenerator很容易做到这一点:

代码语言:javascript
复制
 val iconGenerator = IconGenerator(activity)
    val window = activity.layoutInflater.inflate(R.layout.myinfo_window,null)
    iconGenerator.setContentView(window)
    iconGenerator.setBackground(activity.getDrawableCompat(R.drawable.mybox_bg))
    return googleMap.addMarker(MarkerOptions()
            .position(location)
            .icon(BitmapDescriptorFactory.fromBitmap(iconGenerator.makeIcon())))

然后,myinfo_window.xml看起来像这样:

代码语言:javascript
复制
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:padding="13dp"
android:layout_height="wrap_content">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Cool LOCATION"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"/>

</android.support.constraint.ConstraintLayout>

注意:R.drawable.mybox_bg是一个可绘制的9补丁。

票数 1
EN

Stack Overflow用户

发布于 2019-07-12 18:22:51

你可以很容易地添加信息窗口到谷歌地图。

静态最终LatLng墨尔本=新LatLng(-37.81319,144.96298);标记墨尔本=mMap.addMarker(新MarkerOptions() .position(墨尔本).title(“墨尔本”));melbourne.showInfoWindow();

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56862505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档