I'm new to Android development and have some question regarding overlays in googlemaps API.
What I'm trying to achieve is a class that adds one and only one marker at the position where you tap, I want this overlay to be active only when a button "add marker" is pressed. I've solved this problem in two different ways and I'm not completely satisfied with either one of them.
My solutions is as follows:
first attempt: A bool that turns true when "add button" is pressed, then you are able to put a marker on the map and the boolean value turns false.
This feels quite ugly and the overlay is always active and listens to every tap on the display, maybe this is't that dumb as I believe.
second attempt: Temporary creates the overlay that creates the marker and then immediately removes it self.
This solution I just can't find efficient... Creating new overlay before creating a new marker.
Is there any way to just activate the overlay when "add button" is pressed? Maybe there is some other way to do this?
Is there any way to just activate the overlay when "add button" is pressed?
Don't add it to the overlays list until the add button is pressed.