onclickandroid-mapviewmarkernutiteq

Android Nutiteq Map geting marker id


I'm developing a map application using nutiteq mapview. I added multiple markers on my map and every marker has a click action. I handle marker click in 'onVectorElementClicked' function but it doesn't give me my clicked marker's id, only gives to me marker's label title.

((DefaultLabel) vectorElement.getLabel()).getTitle()

Is there any marker index handle function?

I SOLVED:

When i add marker with for loop, i can set data to marker. This is last parameter of adsMarker . As you can see below the code, i can set my for loop's index in a created marker of parameter. So in 'onVectorElementClicked', i can call it using vectorElement.userData

for(int i = 0; i<list.size(); i++){

            markersLocations = mapLayer.getProjection().fromWgs84(list.get(i).y,list.get(i).x);
            Marker adsMarkers = new Marker(markersLocations, markerLabel, markerStyle_, i);
            advMarkersLayers.add(adsMarkers);
            BasarTrafik.getInstance().setAdsMarker(adsMarkers);

        }

Solution

  • When you add marker with for loop, i can set data to marker. This is last parameter of Marker constructor. As you can see below the code, i can set my for loop's index in a created marker of parameter. So in 'onVectorElementClicked', i can call it using vectorElement.userData

        for(int i = 0; i<list.size(); i++){
    
            markersLocations = mapLayer.getProjection().fromWgs84(list.get(i).y,list.get(i).x);
            Marker adsMarkers = new Marker(markersLocations, markerLabel, markerStyle_, i);
            advMarkersLayers.add(adsMarkers);
            BasarTrafik.getInstance().setAdsMarker(adsMarkers);
    
        }