1

I am trying to write an android application that use google map to show some points (shop places) on the map. I have shop specifications including LatLng, title, etc on a database server and have a rest api to access them. my problem is the total amount of shops are too much, so I can't get all of them and show them on the map, so I need to have some kind of lazy loading showing to access just shops that are required.

I found this link, but it isn't lazy loading, what I understood is that it gets all the item first and show them with marker, which isn't what exactly I need.

Is it possible to do this? if yes how ? please give me some example or tutorial if it is possible.

thanks in advance.

Mohamad MohamadPoor
  • 1,350
  • 2
  • 14
  • 35

1 Answers1

1

Why you dont use Google Maps Android Marker Clustering Utility?

I used to load 12000 markers in a map and is ok for me. I load all of this markers at the same time.

To use lazy loading you can determine the viewable map area and load only this markers.

You can use OnCameraChangeListener to determine it:

map.setOnCameraChangeListener(new OnCameraChangeListener() {
    @Override
    public void onCameraChange(CameraPosition position) {
        BOUNDS = map.getProjection().getVisibleRegion().latLngBounds;
        Float mapZoom = map.getCameraPosition().zoom;
        LatLng latlong = map.getCameraPosition().target;
        updateItems(BOUNDS);
        mapZoom = map.getCameraPosition().zoom;
    }
});
João Marcos
  • 3,872
  • 1
  • 19
  • 14