从绘制在谷歌地图版本2将图像作为标记标记、图像、版本、地图

2023-09-04 09:21:22 作者:走。永不回头

我用这部分的code添加标记在 MapFragment 在谷歌地图版本2。

I am using this part of code to add a marker in a MapFragment in Google Map Version 2.

MarkerOptions op = new MarkerOptions();
op.position(point)
    .title(Location_ArrayList.get(j).getCity_name())
    .snippet(Location_ArrayList.get(j).getVenue_name())
    .draggable(true);
m = map.addMarker(op); 
markers.add(m);

我想从我的绘制使用不同的图像。任何帮助将AP preciated。

I want to use different images from my drawable. Any help will be appreciated.

推荐答案

这是如何设置的任何可绘制为标记

This is how you can set any drawable as a Marker

BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.current_position_tennis_ball)


            MarkerOptions markerOptions = new MarkerOptions().position(latLng)
                     .title("Current Location")
                     .snippet("Thinking of finding some thing...")
                     .icon(icon);

            mMarker = googleMap.addMarker(markerOptions);