How do I access all the tags on my google map object (Android maps V2) and set them to (visible)?
I am currently trying to implement an actionbar button to set all tags on my google map object to be visible or invisible when using it. My problem is that I don't know how to reference it after creating and displaying all tags on the map. I am looking for a solution. I store all tag objects in an array, I can access other parts of my code. Is this reasonable?
This is what I was thinking:
private Marker[] mMarkerArray = null;
for (int i = 0; i < MainActivity.customers.size(); i++) {
LatLng location = new LatLng(mData.lat, mData.lng);
Marker marker = mMap.addMarker(new MarkerOptions().position(location)
.title(mData.title)
.snippet(mData.snippet));
mMarkerArray.add(marker);
}
And set all tags invisible in another method:
for (int i = 0; i < mMarkerArray.length;; i++) {
mMarkerArray[i].setVisible(false);
}
It refuses to add tags to the marker [] – array. How can I implement it?
Mmarkerarray. Add (tag) does not work
resolvent:
I came up with an answer. My customerlist makes customers have no coordinates – > (0,0; 0,0). The inspiration comes from this blog
Initialize ArrayList:
private ArrayList<Marker> mMarkerArray = new ArrayList<Marker>();
Add tags to my map and mmarkerarray:
for (int i = 0; i < MainActivity.customers.size(); i++) {
Customer customer = MainActivity.customers.get(i);
if (customer.getLon() != 0.0) {
if (!customer.isProspect()) {
Data mData= new Data(customer.getLat(),customer.getLon(),customer.getName(),
customer.getOrt());
LatLng location = new LatLng(mData.lat, mData.lng);
Marker marker = mMap.addMarker(new MarkerOptions().position(location)
.title(mData.title)
.snippet(mData.snippet));
mMarkerArray.add(marker);
}}}
Set all tags invisible
for (Marker marker : mMarkerArray) {
marker.setVisible(false);
//marker.remove(); <-- works too!
}