Android – how to make two Google Maps listeners? setOnCameraChangeListener

How do I create two listeners? One is used for clustering, and the other loads a new cluster item into the map if there is no cluster item on the map

       //needed for clustering
       map.setOnCamerachangelistener(mClusterManager);

       // need for loading clusteritems
       map.setOnCamerachangelistener(new GoogleMap.OnCamerachangelistener() {
       @Override
       public void onCameraChange(CameraPosition position) {

       // ifMarkesnotinsideMapReload...

I don't think it's possible, but someone may solve this problem

One idea is to set a starting position and manually poll for changes.. not cool: -)

I am using the Google cluster Library: Google cluster

resolvent:

I have studied the clustermanager implementation of amutils library. If it also implements oncamerachangelistener, it looks like you call oncamerachange on the implementation of clusterrender. Just make it implement this interface

Relevant parts of the code:

@Override
public void onCameraChange(CameraPosition cameraPosition) {
    if (mRenderer instanceof GoogleMap.OnCamerachangelistener) {
        ((GoogleMap.OnCamerachangelistener) mRenderer).onCameraChange(cameraPosition);
    }

If you are using defaultclusterrendeder, create a class, such as:

public class MyClusterRenderer extends DefaultClusterRenderer implements OnCamerachangelistener {

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>