Reputation: 111
I want change map
marker
with scroll the recyclerView
. But with use onScrollStateChanged
method and set my LatLng
, can't change marker and move camera!
Now, how to change marker with scroll the RecyclerView
?
And, What is the best practice to do this?
Thank you.
Upvotes: 0
Views: 494
Reputation: 2606
Your code to set marker and animate camera should look something like this. Hope this helps
private void setLocationToMap(LatLng latLng) {
if (googleMap != null) {
MarkerOptions myLocation = new MarkerOptions();
myLocation.position(latLng);
googleMap.clear();
googleMap.addMarker(myLocation);
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
myMarker = latLng;
}
}
Upvotes: 1