Android Custom marker icon

不问归期 提交于 2019-11-28 10:45:52

With the new Maps Api Setting the Icon for a Marker is done with the following Code:

MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_location));

The icon can not be changed after a Marker was created. To change an icon remove the marker and readd it with a new image.

with the APi v2, you can do (markerObject).setIcon(BitmapDescriptor) to change/set the marker image.

ravuya

OverlayItem.setMarker seems like the method you're looking for.

Note that there is (or used to be) a gotcha you need to be aware of; you first need to use Drawable.setBounds to set the visible boundaries of the drawable before it can be rendered properly. Some fiddling might be needed to get it to centre; see this answer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!