Ok, i got it. This is how i do it. What i wanted is just to store some values in the marker and then recover them with the listener function, but it is not possible to store values in the marker so i create a table to store the needed values. I save the id of the marker and then i check the table in the listener function to know where are the values of the current marker.
myMarkers={}
I have a loop to create several markers:
local options = { title = markerdata[3], subtitle = markerdata[4], listener = markerListener, imageFile = "player\_"..markerdata[1].."\_"..markerdata[2]..".png", } local getid=map:addMarker(markerdata[5], markerdata[6], options ) --Store whatever you need here... myMarkers[#myMarkers + 1]={id=getid,name=markerdata[3],uid=markerdata[4]}
Then in the listener function i look the value of event.markerId to match with the value of stored id.
local function markerListener(event) for i=1,#myMarkers do if (myMarkers[i].id== event.markerId) then native.showAlert( myMarkers[i].uid,myMarkers[i].name, { "ok" } ) end end return true end
So now it is easy to access stored values of that marker…
I update my map every certains seconds so dont forget to clean de table and remove all markers:
map:removeAllMarkers() --clean table with markers for i=1,#myMarkers do table.remove(myMarkers,i) end myMarkers={}