简体   繁体   English

更改地图标记的位图

[英]Change bitmap of a map marker

Is it possible to change the icon of an existing map marker in Google Maps Android API v2? 是否可以在Google Maps Android API v2中更改现有地图标记的图标? I want to highlight the marker after the user clicks on it. 我想在用户单击标记后突出显示该标记。

With the latest Google Play Services (rev7), you can highlight a marker by swapping in a different icon using the setIcon method. 使用最新的Google Play服务(rev7),您可以使用setIcon方法交换其他图标来突出显示标记。

googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
   @Override
   public boolean onMarkerClick(Marker marker) {
       marker.setIcon(BitmapDescriptorFactory
           .fromResource(R.drawable.highlighted_pin)); 
   }
});

... and I just now noticed MaciejGórski 's comment .... ...我刚才注意到MaciejGórski的评论...。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM