我想显示类似android - 一次在每个标记上显示信息窗口-LMLPHP的内容

我能够在 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:



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



更新:使用气泡图标的示例(考虑到您需要在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);

10-05 20:49
查看更多