Open URL from custom info window, Android Google M

2019-03-04 01:35发布

I am using android google maps api v2 with many markers displayed on it. Each time you click on a marker a custom info window with specific tittle/snippet is open. The problem is that I cannot click on the URL "www.news.com". Please find below the options of my marker. How can I specify that the "www.news.com" is a HTML URL link inside the .snippet attribute, and when user clicking on it to open directly in mobiles explorer?

mMap.addMarker(new MarkerOptions()
        .position(new LatLng(39.686286, 19.838443))
        .title("HELLO")
        .snippet("Name: \nSurname: \nphone: XXX \nwebsite: www.news.com")
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.location_icon)));

1条回答
放荡不羁爱自由
2楼-- · 2019-03-04 02:08

From the documentation (my emphasis):

As mentioned in the previous section on info windows, an info window is not a live View, rather the view is rendered as an image onto the map. As a result, any listeners you set on the view are disregarded and you cannot distinguish between click events on various parts of the view. You are advised not to place interactive components — such as buttons, checkboxes, or text inputs — within your custom info window.

The url cannot be clicked separately from the info window as a whole. You may consider assigning a click listener to the info window itself, and navigating to the appropriate webpage whenever the info window is clicked.

查看更多
登录 后发表回答