java - Change marker color in Google Maps V2 -
i'm trying change color of marker.
i have this:
private void addmarker(googlemap map, double lat, double lon, int title, int snippet) { map.addmarker(new markeroptions().position(new latlng(lat, lon)) .title(getstring(title)) .snippet(getstring(snippet)));
and add marker:
addmarker(map, 40.748963847316034, -73.96807193756104, r.string.title, r.string.snippet);
i want change color of marker , thought easy , implement this:
private void addmarker(googlemap map, double lat, double lon, int title, int snippet, int icon) { map.addmarker(new markeroptions().position(new latlng(lat, lon)) .title(getstring(title)) .snippet(getstring(snippet)) .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.(getstring(icon)));
and:
addmarker(map, 40.748963847316034, -73.96807193756104, r.string.title, r.string.snippet, hue_azure);
but can't use "getstring" ".icon" apparently.
how can this?
also, method of changing color supported api 8+? i've had lots of problems supporting api 8+ , suck if broke something...
here loop set markers different colors on map , works great me:
for (task temptask : taskslistappobj.getinstance().tasksrepository.gettasksrepository()) { latlng latlng = new latlng(temptask.getlatitude(), temptask.getlongtitude()); if (temptask.getstatus().contentequals(taskslistactivity.status_waiting)) { newmarker = map.addmarker(new markeroptions().position(latlng).title(temptask.gettitle()).icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_blue))); } else if (temptask.getstatus().contentequals(taskslistactivity.status_in_progress)) { newmarker = map.addmarker(new markeroptions().position(latlng).title(temptask.gettitle()).icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_bordo))); } else if (temptask.getstatus().contentequals(taskslistactivity.status_on_the_way)) { newmarker = map.addmarker(new markeroptions().position(latlng).title(temptask.gettitle()).icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_turkiz))); } else if (temptask.getstatus().contentequals(taskslistactivity.status_complete)) { newmarker = map.addmarker(new markeroptions().position(latlng).title(temptask.gettitle()).icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_orange))); } else if (temptask.getstatus().contentequals(taskslistactivity.status_failed)) { newmarker = map.addmarker(new markeroptions().position(latlng).title(temptask.gettitle()).icon(bitmapdescriptorfactory.fromresource(r.drawable.marker_for_map_purpul))); } }
see if it's helps you.
the if statements changing marker icon.
Comments
Post a Comment