1

I'm using Google Map API to show all locations in database. When user scrolls to one point in map, every visible area on map should be checked and return all locations in my database.

Because user can zoom in / zoom out in map, so minimum and maximum coordinate can view on map is vary base on scaling (and maybe phone screen size, too). So my question is, does android google map sdk supports function, so I can called to get minimum/maximum coordinate (in latitude, longitude) can be showed on map.

Thanks :)

hqt
  • 29,632
  • 51
  • 171
  • 250
  • Take a look at my answer here: http://stackoverflow.com/questions/25517170/adding-markers-in-background-while-looping-through-arraylist/25517475#25517475, in short. If you use https://code.google.com/p/android-maps-extensions/ you can add all the markers once, but they will only actually be displayed (which is the expensive part of the operation) if visible. – cYrixmorten Nov 18 '14 at 15:57
  • Now that I re-read your question, I am not sure my answer fits your needs. And then again.. I think you might be able to query the map for currently visible markers. If that is possible, then the above comment combined with getting the currently visible markers will both 1) effectively load only visible markers 2) enable to get the locations matching the visible area – cYrixmorten Nov 18 '14 at 16:10

1 Answers1

5

I think you can use this code for determining map's bounds

GoogleMap map;

        map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
            @Override
            public void onCameraChange(CameraPosition cameraPosition) {
                //those are corners of visible region
                VisibleRegion visibleRegion = map.getProjection().getVisibleRegion();
                LatLng farLeft = visibleRegion.farLeft;
                LatLng farRight = visibleRegion.farRight;
                LatLng nearLeft = visibleRegion.nearLeft;
                LatLng nearRight = visibleRegion.nearRight;


            }
        });
Serhii Nadolynskyi
  • 5,473
  • 3
  • 21
  • 20