Пример #1
1
  @Override
  /**
   * - Capture the clicked cluster so we can use it in custom infoWindow - Check overall bounds of
   * items in cluster - If the bounds are empty (all hosts at same place) then let it pop the info
   * window - Otherwise, move the camera to show the bounds of the map
   */
  public boolean onClusterClick(Cluster<HostBriefInfo> cluster) {
    mLastClickedCluster = cluster; // remember for use later in the Adapter

    // Find out the bounds of the hosts currently in cluster
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (HostBriefInfo host : cluster.getItems()) {
      builder.include(host.getLatLng());
    }
    LatLngBounds bounds = builder.build();

    // If the hosts are not all at the same location, then change bounds of map.
    if (!bounds.southwest.equals(bounds.northeast)) {
      // Offset from edge of map in pixels when exploding cluster
      View mapView = findViewById(R.id.map_fragment);
      int padding_percent = getResources().getInteger(R.integer.cluster_explode_padding_percent);
      int padding = Math.min(mapView.getHeight(), mapView.getWidth()) * padding_percent / 100;
      CameraUpdate cu =
          CameraUpdateFactory.newLatLngBounds(
              bounds, mapView.getWidth(), mapView.getHeight(), padding);
      mMap.animateCamera(cu);
      return true;
    }
    showMultihostSelectDialog((ArrayList<HostBriefInfo>) cluster.getItems());
    return true;
  }
 protected void onCameraChange(CameraPosition cameraPosition, ViewPortChangeListener listener) {
   // If custom tile overlay is enabled, use rounded zoom to avoid
   // tiles blurring
   if (customTileOverlay != null) {
     int roundZoom = Math.round(cameraPosition.zoom);
     if (Math.abs(cameraPosition.zoom - roundZoom) > 0.01) {
       CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(roundZoom);
       googleMap.animateCamera(cameraUpdate);
       return;
     }
   }
   GeoRect viewPort = getViewPortGeoRect();
   listener.onViewPortChanged(viewPort);
 }