gpt4 book ai didi

google-maps - .snippet 中的多行或换行(谷歌地图 apiv2)

转载 作者:行者123 更新时间:2023-12-04 02:59:02 25 4
gpt4 key购买 nike

我正在使用谷歌地图 APIv2 进行开发。我现在面临的问题是我只能在信息窗口/片段中添加一行单词。但是我想要的输出能够以折线形式显示,如下面的示例所示。那么有没有可能的方法来解决呢?

例子:

坐标:03.05085、101.70506

限速:80 公里/小时

public class MainActivity extends FragmentActivity {
static final LatLng SgBesi = new LatLng(03.05085, 101.76022);
static final LatLng JB = new LatLng(1.48322, 103.69065);
private GoogleMap map;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();

map.addMarker(new MarkerOptions().position(SgBesi)
.title("KM D7.7 Sungai Besi") //name
.snippet("Coordinate: 03.05085, 101.70506")); //description

map.addMarker(new MarkerOptions().position(JB)
.title("test")
.snippet("Hey, how are you?"));

// .icon(BitmapDescriptorFactory //set icon
// .fromResource(R.drawable.ic_launcher)));

// move the camera instantly with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SgBesi, 15));

// zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
}
}

最佳答案

您需要使用 custom InfoWindowAdapter更改 InfoWindow 的布局到使用布局文件定义的定制设计。基本上你需要:

  • 使用 GoogleMap.setInfoWindowAdapter(Yourcustominfowindowadpater) 声明你的函数
  • 有一个像下面这样的类(class):

  • ...

    class Yourcustominfowindowadpater implements InfoWindowAdapter {
    private final View mymarkerview;

    Yourcustominfowindowadpater() {
    mymarkerview = getLayoutInflater()
    .inflate(R.layout.custominfowindow, null);
    }

    public View getInfoWindow(Marker marker) {
    render(marker, mymarkerview);
    return mymarkerview;
    }

    public View getInfoContents(Marker marker) {
    return null;
    }

    private void render(Marker marker, View view) {
    // Add the code to set the required values
    // for each element in your custominfowindow layout file
    }
    }

    关于google-maps - .snippet 中的多行或换行(谷歌地图 apiv2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17391445/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com