底部没有小三角形的地图标记信息窗口 [英] Map marker info window without small triangle at bottom

查看:118
本文介绍了底部没有小三角形的地图标记信息窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在底部显示没有小三角形的Google地图标记的Infowindow。请检查我附加的图像。





我尝试了通过更改setInfoWindowAnchor进行设置,但它不起作用。任何人都可以帮助我吗?

  marker_info.setInfoWindowAnchor(0,0)


解决方案

为了使用speechbubble,请使用 getInfoContents()

为了不使用speechbubble,使用 getInfoWindow() override。

示例1:

  public class MyCustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter { 

private final查看myContentsView;

MyCustomInfoWindowAdapter(){
myContentsView = getLayoutInflater()。inflate(
R.layout.info_window,null);
}

@Override
public View getInfoWindow(Marker marker){
return null;

$ b @Override
public View getInfoContents(Marker marker){

TextView tvTitle =((TextView)myContentsView
.findViewById( R.id.txtTitle));
TextView tvSnippet =((TextView)myContentsView
.findViewById(R.id.txtSnippet));

tvTitle.setText(marker.getTitle());
tvSnippet.setText(marker.getSnippet());

返回myContentsView;


$ / code $ / pre
$ b $结果:



示例2:

  public class MyCustomInfoWindowAdapter实现GoogleMap.InfoWindowAdapter {

private final查看myContentsView;

MyCustomInfoWindowAdapter(){
myContentsView = getLayoutInflater()。inflate(
R.layout.info_window,null);
}

@Override
public View getInfoWindow(Marker marker){
TextView tvTitle =((TextView)myContentsView
.findViewById(R.id。 txtTitle));
TextView tvSnippet =((TextView)myContentsView
.findViewById(R.id.txtSnippet));

tvTitle.setText(marker.getTitle());
tvSnippet.setText(marker.getSnippet());

返回myContentsView;
}

@Override
public View getInfoContents(Marker marker){

return null;


$ / code $ / pre
$ b $结果:



注,这是使用的info_window.xml布局文件:

 <?xml version =1.0encoding =utf-8 >?; 
< LinearLayout xmlns:android =http://schemas.android.com/apk/res/android
android:layout_width =match_parent
android:layout_height =match_parent
android:padding =20dp
android:orientation =vertical
android:background =#000000>

TextView
android:id =@ + id / txtTitle
android:textColor =#D3649F
android:textStyle =bold
android:layout_width =wrap_content
android:layout_height =wrap_content/>

TextView
android:id =@ + id / txtSnippet
android:textColor =#D3649F
android:layout_width =wrap_content
android:layout_height =wrap_content/>

< / LinearLayout>


I need to show an Infowindow of a Google map marker without the small triangle at the bottom. Please check the image which I have attached.

I tried by setting by changing setInfoWindowAnchor but it didn't work. Can anyone help me on this?

marker_info.setInfoWindowAnchor(0,0)

解决方案

In order to use the speechbubble, use the getInfoContents() override.

In order to not use the speechbubble, use getInfoWindow() override.

Example 1:

public class MyCustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

    private final View myContentsView;

    MyCustomInfoWindowAdapter() {
        myContentsView = getLayoutInflater().inflate(
                R.layout.info_window, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        return null;
    }

    @Override
    public View getInfoContents(Marker marker) {

        TextView tvTitle = ((TextView) myContentsView
                .findViewById(R.id.txtTitle));
        TextView tvSnippet = ((TextView) myContentsView
                .findViewById(R.id.txtSnippet));

        tvTitle.setText(marker.getTitle());
        tvSnippet.setText(marker.getSnippet());

        return myContentsView;
    }
}

Result:

Example 2:

public class MyCustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

    private final View myContentsView;

    MyCustomInfoWindowAdapter() {
        myContentsView = getLayoutInflater().inflate(
                R.layout.info_window, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        TextView tvTitle = ((TextView) myContentsView
                .findViewById(R.id.txtTitle));
        TextView tvSnippet = ((TextView) myContentsView
                .findViewById(R.id.txtSnippet));

        tvTitle.setText(marker.getTitle());
        tvSnippet.setText(marker.getSnippet());

        return myContentsView;
    }

    @Override
    public View getInfoContents(Marker marker) {

       return null;
    }
}

Result:

Note, here is the info_window.xml layout file used:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="20dp"
    android:orientation="vertical"
    android:background="#000000">

    <TextView
        android:id="@+id/txtTitle"
        android:textColor="#D3649F"
        android:textStyle="bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/txtSnippet"
        android:textColor="#D3649F"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

这篇关于底部没有小三角形的地图标记信息窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆