Android Spinner to determine Marker Colour
Android Spinner to determine Marker Colour
I have a spinner which I have created for a project in Android studio. The spinner takes the following values from an array in my strings.xml file.
<string-array name="activity_types">
<item>Games</item>
<item>Learn</item>
<item>Fitness</item>
<item>Make</item>
<item>Explore</item>
<item>Find</item>
</string-array>
I would like to create a function which places a marker of a particular colour onto my map in MainActivity i.e. selecting Games, will place an orange marker on the map, when 'Games' is selected and the 'Place' button (below) is pressed. However, I am not sure how to go about this?
place_btn = (Button) findViewById(R.id.place_btn);
place_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//what would handle the spinner elements here?
//my marker
static final LatLng EXAMPLELOCATION = new LatLng(-37.813, 144.962);
Marker examplelocation = mMap.addMarker(new MarkerOptions()
.position(EXAMPLELOCATION)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE)));
//go to my main activity, once the marker is placed
openMainActivity();
}
});
I can see that the Google Maps SDK heading under 'Customise the marker colour' provides a function for handling adding a marker, based on colour, so I guess I am just trying to understand how to tie this into a selection from my spinner?
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.