Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Maps API v2 - how to change marker icon

I am trying to change marker icon. I get the image from one server directory.

When I put break point every time the "bit" result is null. And when I run the app I get java.lang.NullPointerException.

File file = new File("J:\\!!! DOCUMENTS\\!Outsourcing\\AppStore\\Benzinostancii\\Petrol\\logo.png");  Bitmap bit = BitmapFactory.decodeFile(String.valueOf(file));  double Dlat = lat.get(index); double Dlon = lon.get(index); String info = Arrayinfo.get(index); String name = Arrayname.get(index);  LatLng coordinate = new LatLng(Dlat, Dlon); map.addMarker(new MarkerOptions()     .icon(BitmapDescriptorFactory.fromBitmap(bit))     .position(coordinate)     .title(info) ).setSnippet(name); 
like image 506
cross_fire Avatar asked Aug 28 '13 11:08

cross_fire


People also ask

How do I change the color of a marker on Google Maps?

To edit the marker color, click or tap on the marker icon. When you do that, you can change both the color of the marker and its style. Go for the color or style you want to change and then click OK to see the effect. Click on the button labeled Done to save your new marker color settings.


1 Answers

// latitude and longitude double latitude = 17.385044; double longitude = 78.486671;  // create marker MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps");  // Changing marker icon marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.my_marker_icon)));  // adding marker googleMap.addMarker(marker); 

More Info

like image 192
TharakaNirmana Avatar answered Sep 20 '22 19:09

TharakaNirmana