Android Custom marker icon

后端 未结 4 1277
离开以前
离开以前 2020-12-17 09:08

I\'m working on application with Google maps so i want to define a custom marker for each custom place, For example (gas station- Hotel- Hospital.. ) ! i have a overlays cla

相关标签:
4条回答
  • 2020-12-17 09:36

    To change the color of the map icon:

    mMap.addMarker(new MarkerOptions().position(baitulMosque).title("Baitul Mosque").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN)));
    
    0 讨论(0)
  • 2020-12-17 09:42

    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.

    0 讨论(0)
  • 2020-12-17 09:50

    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.

    0 讨论(0)
  • 2020-12-17 09:56

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

    0 讨论(0)
提交回复
热议问题