标记没有显示

时间:2017-10-04 04:12:42

标签: android google-maps marker

当我尝试添加这样的标记时,它没有显示

Marker marker = mMap.addMarker(new MarkerOptions().position(transitLatLong).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin))

但是当我尝试下面的一个而没有分配标记对象时它会显示

mMap.addMarker(new MarkerOptions().position(transitLatLong).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin))

1 个答案:

答案 0 :(得分:0)

尝试这种方式:

private Marker marker;

    MarkerOptions options = new MarkerOptions();

    //Setting position
    options.position(latLng);

    //Bitmap from Resource
    Bitmap bit = getBitmapFromVectorDrawable(fa, R.drawable.map_pin); 

    //Setting bitmap
    options.icon(BitmapDescriptorFactory.fromBitmap(bit));

    //Finally add to the map
    marker = map.addMarker(options);

如果您要删除标记:

   if (marker != null)
       marker.remove();