mapMarkers, how to hold more information?

I have a bunch of map markers that I’m loading from a database. 

Later, when tapped, users can navigate to the map marker.

I’d like to also be able to save/read extra information on a marker. Here’s exactly my objective.

The database tells me who created the marker, when THAT user taps the marker I want to add a ‘Delete’ option to the showAlert so the creator can remove the marker. The issue is that I don’t think I can add a custom entry to the marker (eg: myMarker.userID), and I wasn’t sure if or how to link the marker elsewhere.

I could do another select when I tap the marker, but I didn’t want to do a database hit there, I thought I should be able to achieve it more easily.

Thoughts?

Unfortunately there weren’t any thoughts  :smiley: but I did find a solution to the question which proved quite simple. I thought I’d post the solution in case others wander across the post with similar questions.

Simply, I used a table to hold all the information I wanted, and I access the table using the markerID # that was was assigned. 

 for i=1, #evt.result do local markeridx,errormsg=myMap:addMarker(evt.result[i].latitude,evt.result[i].longtitude,{listener = markerListener,imageFile="bulb.png"}) print( "addmarkerstomap:Added # "..i ) if markeridx ~= nil then local midx = #common.marker+1 common.marker[midx] = {} common.marker[midx].marker = {} common.marker[midx].userID = {} common.marker[midx].test = {} common.marker[midx].marker = markeridx common.marker[midx].userID = evt.result[i].userID common.marker[midx].test = "Test for marker # "..markeridx end end

Later in the marker listener, I can use something like

common.marker[event.markerId].test 

to reference values in the table. So for my specific example in the topic, I can look at common.marker[event.markerId].test and compare it to the user in the app for a match.

 

Unfortunately there weren’t any thoughts  :smiley: but I did find a solution to the question which proved quite simple. I thought I’d post the solution in case others wander across the post with similar questions.

Simply, I used a table to hold all the information I wanted, and I access the table using the markerID # that was was assigned. 

 for i=1, #evt.result do local markeridx,errormsg=myMap:addMarker(evt.result[i].latitude,evt.result[i].longtitude,{listener = markerListener,imageFile="bulb.png"}) print( "addmarkerstomap:Added # "..i ) if markeridx ~= nil then local midx = #common.marker+1 common.marker[midx] = {} common.marker[midx].marker = {} common.marker[midx].userID = {} common.marker[midx].test = {} common.marker[midx].marker = markeridx common.marker[midx].userID = evt.result[i].userID common.marker[midx].test = "Test for marker # "..markeridx end end

Later in the marker listener, I can use something like

common.marker[event.markerId].test 

to reference values in the table. So for my specific example in the topic, I can look at common.marker[event.markerId].test and compare it to the user in the app for a match.