【问题标题】:How to make a marker tag like uber?如何制作像uber这样的标记标签?
【发布时间】:2018-05-14 17:12:05
【问题描述】:

我想在我的标记旁边显示一个类似于 uber 应用程序中的标签。如何在谷歌地图中制作这样的标签?

我已经尝试添加标题和 sn-p。但这不是我想要的。

 mMap.addMarker(new MarkerOptions()
                        .position(MELBOURNE)
                        .title("6 min away")
                        .snippet("Pick up point ")
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.pickup_2x)));

这就是我通过@Nirmal 得到的答案。它仍然不是我想要的

【问题讨论】:

    标签: java android google-maps bitmap google-maps-markers


    【解决方案1】:

    info_window_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:orientation="horizontal">
    
        <wm.com.taxiapp.view.CustomTextView
            android:id="@+id/tv_distance"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2.5"
            android:background="@android:color/black"
            android:gravity="center"
            android:paddingLeft="@dimen/space_10"
            android:paddingRight="@dimen/space_10"
            android:text="2\nMIN"
            android:textColor="@android:color/white"
            android:textSize="@dimen/font_8" />
    
        <ImageView
            android:id="@+id/iv_scheduled_ride"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2.5"
            android:background="@android:color/black"
            android:gravity="center"
            android:paddingLeft="@dimen/space_10"
            android:paddingRight="@dimen/space_10"
            android:src="@drawable/time"
            android:visibility="gone" />
    
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="6"
            android:background="@android:color/white"
            android:orientation="vertical">
    
            <wm.com.taxiapp.view.CustomTextView
                android:id="@+id/tv_lat"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:ellipsize="end"
                android:maxLines="1"
                android:paddingLeft="@dimen/space_5"
                android:paddingRight="@dimen/space_5"
                android:paddingTop="@dimen/space_3dp"
                android:scrollbars="none"
                android:text=" "
                android:textColor="@color/hintColor"
                android:textSize="@dimen/font_12" />
    
            <wm.com.taxiapp.view.CustomTextView
                android:id="@+id/tv_lng"
                android:layout_width="@dimen/space_100"
                android:layout_height="match_parent"
                android:ellipsize="end"
                android:maxLines="1"
                android:paddingBottom="@dimen/space_3dp"
                android:paddingLeft="@dimen/space_5"
                android:scrollbars="none"
                android:text=""
                android:textColor="@color/hintColor"
                android:textSize="@dimen/font_12" />
    
        </LinearLayout>
    
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:src="@drawable/arrow_right" />
    
    </LinearLayout>
    

    在信息窗口中扩充此布局文件mMap.setInfoWindowAdapter

    【讨论】:

    • 这没有帮助。仍然不是我想要的。我用你的回答得到的图片编辑了我的帖子。
    • 您必须在地图上实现 infowindow 并将此布局膨胀到您的信息窗口中。
    • 哦,好的,我现在知道了。我已经用getInfoContents 膨胀它,而不是用getInfoWindow。再次感谢!
    • @NirmalPrajapat 这里的 wm.com.taxiapp.view.CustomTextView 是什么?
    • @JayRathodRJ ,我刚刚自定义了TextView,你可以自定义或者使用普通的TextView。
    猜你喜欢
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多