1

我正在尝试将一个网站和(希望)一个电话号码链接到我在地图上创建的地图标记的片段中。有没有办法做到这一点?如果不是,还有什么方法可以在单击的标记上方显示包含可点击网站和可点击电话号码的内容。我在考虑一个警报对话框,但我不知道如何为动态制作的地图标记设置 onClickListeners。

public void addWayPointMarkers(LatLng point){
    MarkerOptions marker = new MarkerOptions();
    marker.title(name);
    marker.snippet(Html.fromHtml(address + "<br />" + phone + "<br />" + "<a href=\"" + website + "\">Website</a>"));       
    marker.position(point);

    map.addMarker(marker);
}
4

1 回答 1

4

如果您希望链接可点击,这将不起作用

The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (e.g., after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.

但是,如果您愿意,可以在单击标记时显示包含信息的对话框

于 2013-07-17T16:49:56.917 回答