How to get all visible markers on current zoom level

前端 未结 6 1817
情深已故
情深已故 2020-12-04 08:05

Here are some points:

  1. I have some markers on the map and records associated with it on the right panel besides the map. They are connected via numeric id, whic
6条回答
  •  忘掉有多难
    2020-12-04 08:29

    It's easy code. Try this code.

    private boolean CheckVisibility(Marker marker)
    {
        if(googleMap != null)
        {
            //This is the current user-viewable region of the map
            LatLngBounds latLongBounds = googleMap.getProjection().getVisibleRegion().latLngBounds;
    
                if(latLongBounds.contains(marker.getPosition()))
                       //If the item is within the the bounds of the screen
                      return true;
                else
                      //If the marker is off screen
                      return false;
        }
        return false;
    }
    

提交回复
热议问题