Reputation: 153
Long story short; I got at Bluetooth device measuring signal-strength of other devices in the area, and then I log the GPS positions on the Android app.
I place the positions on a Google map in my app, but I would like the marker to change color depending on the value of signal-strength (0-255) from red to green or something like that.
I think I need to make my own Drawable in the app or change what is in the:
Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
But I can't find a way draw the markers in the android app.
Any ideas?
Upvotes: 0
Views: 5195
Reputation: 1619
I think you have to try similar code below , but it is applicable for default marker only , colors will change depending on hue value , this is snippet from Google Maps API Demos
:
// Creates a marker rainbow demonstrating how to create default marker icons of different
// hues (colors).
int numMarkersInRainbow = 12;
for (int i = 0; i < numMarkersInRainbow; i++) {
mMap.addMarker(new MarkerOptions()
.position(new LatLng(
-30 + 10 * Math.sin(i * Math.PI / (numMarkersInRainbow - 1)),
135 - 10 * Math.cos(i * Math.PI / (numMarkersInRainbow - 1))))
.title("Marker " + i)
.icon(BitmapDescriptorFactory.defaultMarker(i * 360 / numMarkersInRainbow)));
}
Upvotes: 0
Reputation: 6032
Are you using a GoogleMap
? If you have the Drawable-generation down, all you have to do is hook it up via the MarkerOptions.icon
method:
BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.resource);
MarkerOptions opts = new MarkerOptions().icon(descriptor);
this.getMap().addMarker(opts);
This will draw your drawable on the map.
You can replace fromResource
with fromBitmap
if needed.
Upvotes: 1