문제

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