在google maps for android平台上始终显示标记标签和默认pin图标
我需要在地图上显示多个位置。 我希望每个标记的信息/标签与pin图标一起显示在地图上,无论用户是否单击标记/pin。 我有以下代码来显示标记在google maps for android平台上始终显示标记标签和默认pin图标,android,google-maps,Android,Google Maps,我需要在地图上显示多个位置。 我希望每个标记的信息/标签与pin图标一起显示在地图上,无论用户是否单击标记/pin。 我有以下代码来显示标记 for (DepartmentLocation loc : departmentLocations) { if (loc != null && loc.getLatitude() != null && loc.getLongitude() != null) {
for (DepartmentLocation loc : departmentLocations) {
if (loc != null && loc.getLatitude() != null && loc.getLongitude() != null) {
LatLng latLng = new LatLng(loc.getLatitude(), loc.getLongitude());
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
MarkerOptions markerOptions = new MarkerOptions().position(latLng).title(loc.getName());
markerOptions.visible(true);
Marker marker = googleMap.addMarker(markerOptions);
marker.showInfoWindow();
marker.setVisible(true);
markers.add(marker);
}
}
但是,我仍然只看到红色的别针,别针旁边没有标签。
这是我的地图的样子。我只能看到一个信息标签,其他的都看不到。
我已尝试从map utils中使用IconGenerator
实现'com.google.maps.android:android-maps-utils:0.5'
for (DepartmentLocation loc : departmentLocations) {
if (loc != null && loc.getLatitude() != null && loc.getLongitude() != null) {
LatLng latLng = new LatLng(loc.getLatitude(), loc.getLongitude());
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
MarkerOptions markerOptions = new MarkerOptions()
.icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(loc.getName())))
.position(latLng)
.title(loc.getName());
markerOptions.visible(true);
Marker marker = googleMap.addMarker(markerOptions);
marker.showInfoWindow();
marker.setVisible(true);
markers.add(marker);
}
}
当我使用iconfactory时,我无法同时显示pin和信息标签。
从文档中,有一条文字说明信息窗口一次显示一个,因此无法做到这一点: “信息窗口允许您在用户访问时向其显示信息 点击标记。一次只显示一个信息窗口。如果 用户单击一个标记,当前信息窗口将被关闭并显示 将显示新的信息窗口。请注意,如果用户单击 当前显示信息窗口的标记,该信息窗口 关闭并重新打开。”
您可以在此处阅读更多信息:从文档中,有一条文字说明信息窗口一次显示一个,因此无法做到这一点: “信息窗口允许您在用户访问时向其显示信息 点击标记。一次只显示一个信息窗口。如果 用户单击一个标记,当前信息窗口将被关闭并显示 将显示新的信息窗口。请注意,如果用户单击 当前显示信息窗口的标记,该信息窗口 关闭并重新打开。” 您可以在这里阅读更多内容:谷歌地图上一次只显示一个。不能一次显示多个信息窗口 你必须用它。您可以将视图设置为IconGenerator,并从该视图生成位图。您可以创建一个同时包含标记和InfoWindow视图的视图。使用该视图包装所需的标记 您可以选中此项谷歌地图上一次只显示一个。不能一次显示多个信息窗口 你必须用它。您可以将视图设置为IconGenerator,并从该视图生成位图。您可以创建一个同时包含标记和InfoWindow视图的视图。使用该视图包装所需的标记 你可以查一下