gpt4 book ai didi

android - 一次在每个标记上显示信息窗口

转载 作者:IT老高 更新时间:2023-10-28 23:00:33 24 4
gpt4 key购买 nike

我想显示类似 this 的内容

我能够在 map 上显示所有标记,但我想在填充所有标记时在每个标记上显示信息窗口。 到目前为止我已经尝试过了,但它只显示了一个标记信息窗口中的所有标记。

for (int i = 0; i < jobsDtoList.size(); i++) {
Double latitude = Double.parseDouble(jobsDtoList.get(i).getSiteLatitude());
Double longitude = Double.parseDouble(jobsDtoList.get(i).getSiteLongitude());

LatLng latLng = new LatLng(latitude, longitude);
MarkerOptions TP = new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.mipmap.job_marker));
googleMap.addMarker(TP).showInfoWindow();
}

最佳答案

一次不能显示多个信息窗口。来自 the documentation :

An info window allows you to display information to the user when they tap on a marker. Only one info window is displayed at a time. If a user clicks on another marker, the current info window will be hidden and the new info window will be displayed.

您可能想看看 Google Maps Android API Utility Library 中的气泡图标.气泡图标为标记添加了更强大的渲染选项,但不会改变它们的行为。这意味着您仍然不能一次显示多个信息窗口,但气泡图标可以让您在每个标记上显示更多信息:

Add a IconGenerator to display snippets of information on your markers. This utility provides a way of making your marker icons look a bit like info windows, in that the marker itself can contain text and other content. The advantage is that you can keep more than one marker open at the same time, whereas only one info window can be open at once. You can also style the markers, change the orientation of the marker and/or content, and change the marker's background image/nine-patch.

更新:使用气泡图标的示例(考虑到您需要在 this instructions 之后将 Google Maps Android API 实用程序库添加到您的项目中):

LatLng latLng = new LatLng(latitude, longitude);

TextView text = new TextView(context);
text.setText("Your text here");
IconGenerator generator = new IconGenerator(context);
generator.setBackground(context.getDrawable(R.drawable.bubble_mask));
generator.setContentView(text);
Bitmap icon = generator.makeIcon();

MarkerOptions tp = new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(icon));
googleMap.addMarker(tp);

关于android - 一次在每个标记上显示信息窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32984118/

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