Issue
I have added mapview
in the layout. How to set map marker dynamically based on items in the list?
<com.google.android.gms.maps.MapView
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="15"
map:liteMode="false"
map:mapType="normal" />
Solution
In onBindViewHolder
for your map view Implement OnMapReadyCallback
and override onMapReady()
.
Something like this:
holder.mMapView.getMapAsync(new OnMapReadyCallback()
{
@Override
public void onMapReady(GoogleMap googleMap) {
holder.mMapView = googleMap;
if (holder.mMapView != null) {
holder.mMapView.addMarker(...);
}
}
}
Answered By - Hamed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.