I am using a mapview with Google Maps and adding markers to the map using following code:

googleMap.addMarker(new MarkerOptions()
 .icon(BitmapDescriptorFactory.fromResource(getResources().getIdentifier(iconFileName, "drawable", this.getActivity().getPackageName()))));

Is there a more resource-friendly way of doing this?

有帮助吗?

解决方案

What about this code??

googleMap.addMarker(new MarkerOptions().position(currentpos)
            .title("Marker")
            .snippet("My marker.")
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.mark_start)));

其他提示

You can simply load marker from drawable folder as follows...

googleMap.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_file_name));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top