添加标记谷歌地图V2的Android时,会自动打开信息窗口 [英] Opening InfoWindow automatically when adding marker Google Maps v2 Android
问题描述
有没有办法当我们添加一个标记,以自动打开信息窗口? 使用这个code添加的标记,但仅信息窗口点击标记时打开:
myMap.addMarker(新MarkerOptions()
.position(经纬度)
.title伪(标题)
是.snippet(片段)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.marker)));
这是信息窗口,可以显示信息给用户,当他们 轻触地图上的标记。默认情况下,会显示一个信息窗口时, 一个标记,一个用户点击,如果标记有一个标题集。只有一个信息 窗口被显示在一个时间。如果用户点击另一个标记,该 当前窗口会被隐藏,新的信息窗口会 显示。您可以通过调用显示一个信息窗口编程 showInfoWindow()的目标标记。一个信息窗口可以隐藏 调用的的 hideInfoWindow()的
您可以显示信息窗口是这样的:
标记标记= myMap.addMarker(新MarkerOptions()
.position(经纬度)
.title伪(标题)
是.snippet(片段)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.marker)));
marker.showInfoWindow();
Is there a way to open the infowindow automatically when we add a marker? Using this code to add the marker but infowindow only opens when clicking the marker:
myMap.addMarker(new MarkerOptions()
.position(latLng)
.title("Title")
.snippet("Snippet")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.marker)));
According to the documents of Google Maps for Android V2:
An info window allows you to display information to the user when they tap on a marker on a map. By default, an info window is displayed when a user taps on a marker if the marker has a title set. Only one info window is displayed at a time. If a user clicks on another marker, the current window will be hidden and the new info window will be displayed. You can show an info window programmatically by calling showInfoWindow() on the target marker. An info window can be hidden by calling hideInfoWindow().
You can show the info window like this:
Marker marker = myMap.addMarker(new MarkerOptions()
.position(latLng)
.title("Title")
.snippet("Snippet")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.marker)));
marker.showInfoWindow();
这篇关于添加标记谷歌地图V2的Android时,会自动打开信息窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!