コード例 #1
0
ファイル: Maps2Activity.java プロジェクト: gebuh/wsandroid
 private void loadOfflineHosts() {
   mClusterManager.clearItems();
   mClusterManager.getMarkerCollection().clear();
   mHosts.clear();
   mClusterManager.addItems(starredHosts);
   mClusterManager.cluster();
 }
コード例 #2
0
ファイル: Maps2Activity.java プロジェクト: gebuh/wsandroid
  @Override
  public void onCameraChange(CameraPosition position) {
    mLastCameraPosition = position;

    // If not connected, we'll switch to offline/starred hosts mode
    if (!Tools.isNetworkConnected(this)) {
      sendMessage(R.string.map_network_not_connected, false);
      // If we already knew we were offline, return
      if (mIsOffline) {
        return;
      }
      // Otherwise, set state to offline and load only offline hosts
      mIsOffline = true;
      loadOfflineHosts();
      return;
    }

    // If we were offline, switch back on, but remove the offline markers
    if (mIsOffline) {
      mIsOffline = false;
      mClusterManager.clearItems();
      mClusterManager.getMarkerCollection().clear();
      mHosts.clear();
    }

    // And get standard host list for region from server
    LatLngBounds curScreen = mMap.getProjection().getVisibleRegion().latLngBounds;
    Search search = new RestMapSearch(curScreen.northeast, curScreen.southwest);

    if (position.zoom < getResources().getInteger(R.integer.map_zoom_min_load)) {
      sendMessage(R.string.hosts_dont_load, false);
    } else {
      sendMessage(getResources().getString(R.string.loading_hosts), false);
      doMapSearch(search);
    }
  }