Java 类com.google.android.gms.maps.GoogleMap.OnCameraChangeListener 实例源码

项目:XamarinAdmobTutorial    文件:VisibleRegionDemoActivity.java   
/**
 * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
 * installed) and the map has not already been instantiated.. This will ensure that we only ever
 * call {@link #setUpMap()} once when {@link #mMap} is not null.
 * <p>
 * If it isn't installed {@link SupportMapFragment} (and
 * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
 * install/update the Google Play services APK on their device.
 * <p>
 * A user can return to this FragmentActivity after following the prompt and correctly
 * installing/updating/enabling the Google Play services. Since the FragmentActivity may not
 * have been completely destroyed during this process (it is likely that it would only be
 * stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this
 * method in {@link #onResume()} to guarantee that it will be called.
 */
private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
               .getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            // turn MyLocation on and move to a place with indoor (SFO airport)
            mMap.setMyLocationEnabled(true);
            mMap.setPadding(currentLeft, currentTop, currentRight, currentBottom);
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SFO, 18));
            // Add a marker to the Opera House
            mMap.addMarker(new MarkerOptions().position(SOH).title("Sydney Opera House"));
            // Add a camera change listener.
            mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
                public void onCameraChange(CameraPosition pos) {
                  mMessageView.setText("CameraChangeListener: " + pos);
                }
              });
        }
    }
}
项目:HereAStory-Android    文件:VisibleRegionDemoActivity.java   
/**
 * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
 * installed) and the map has not already been instantiated.. This will ensure that we only ever
 * call {@link #setUpMap()} once when {@link #mMap} is not null.
 * <p>
 * If it isn't installed {@link SupportMapFragment} (and
 * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
 * install/update the Google Play services APK on their device.
 * <p>
 * A user can return to this FragmentActivity after following the prompt and correctly
 * installing/updating/enabling the Google Play services. Since the FragmentActivity may not
 * have been completely destroyed during this process (it is likely that it would only be
 * stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this
 * method in {@link #onResume()} to guarantee that it will be called.
 */
private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
               .getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            // turn MyLocation on and move to a place with indoor (SFO airport)
            mMap.setMyLocationEnabled(true);
            mMap.setPadding(currentLeft, currentTop, currentRight, currentBottom);
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SFO, 18));
            // Add a marker to the Opera House
            mMap.addMarker(new MarkerOptions().position(SOH).title("Sydney Opera House"));
            // Add a camera change listener.
            mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
                public void onCameraChange(CameraPosition pos) {
                  mMessageView.setText("CameraChangeListener: " + pos);
                }
              });
        }
    }
}
项目:clusterkraf    文件:SampleActivity.java   
private void initMap() {
    if (map == null) {
        SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
        if (mapFragment != null) {
            map = mapFragment.getMap();
            if (map != null) {
                UiSettings uiSettings = map.getUiSettings();
                uiSettings.setAllGesturesEnabled(false);
                uiSettings.setScrollGesturesEnabled(true);
                uiSettings.setZoomGesturesEnabled(true);
                map.setOnCameraChangeListener(new OnCameraChangeListener() {
                    @Override
                    public void onCameraChange(CameraPosition arg0) {
                        moveMapCameraToBoundsAndInitClusterkraf();
                    }
                });
            }
        }
    } else {
        moveMapCameraToBoundsAndInitClusterkraf();
    }
}
项目:hRouting_Android    文件:PathMapFragment.java   
private void zoomAndDrawLines(ArrayList<LatLng> healthiestPath,
                              ArrayList<LatLng> shortestPath) {
    final LatLngBounds.Builder builder = new LatLngBounds.Builder();
    Set<LatLng> duplicates = getDuplicates(healthiestPath, shortestPath);
    List<PolylineOptions> healthiestList = getPolyLineOptions(
            healthiestPath, duplicates, builder, true);
    List<PolylineOptions> shortestList = getPolyLineOptions(shortestPath,
            duplicates, builder, false);

    List<PolylineOptions> mergedShortest = mergePolylineOptions(shortestList);
    List<PolylineOptions> mergedHealthiest = mergePolylineOptions(healthiestList);

    // Zoom to path once the map has a layout.

    map.setOnCameraChangeListener(new OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition arg0) {
            // Move camera.
            getMap().moveCamera(
                    CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
            // Remove listener to prevent position reset on camera move.
            getMap().setOnCameraChangeListener(null);
        }
    });
    addPolylinesToMap(mergedShortest);
    addPolylinesToMap(mergedHealthiest);
}
项目:Arduino-Navigator    文件:GMapControl.java   
private void setOnCameraChangeListener() {
    mGoogleMap.setOnCameraChangeListener(new OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition pos) {
            mCurrentZoom = pos.zoom;
        }
    });
}
项目:kluster-android    文件:EventMapFragment.java   
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    getLoaderManager().initLoader(URL_LOADER, null, this);

    /*getMap().setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(Marker marker) {
            getMap().setInfoWindowAdapter(new PhotoInfoWindowAdapter(getActivity()));
            marker.showInfoWindow();
            return true;
        }
    });*/

    getMap().setOnCameraChangeListener(new OnCameraChangeListener() {
           @Override
           public void onCameraChange(CameraPosition position) {
               LatLngBounds bounds = getMap().getProjection().getVisibleRegion().latLngBounds;
               double swlong = bounds.southwest.longitude;
               double swlat = bounds.southwest.latitude;
               double nelong = bounds.northeast.longitude;
               double nelat = bounds.northeast.latitude;
            RestAdapter restAdapter = new AuthKlusterRestAdapter()
            .build();
            KlusterService service = restAdapter.create(KlusterService.class);

            service.getEvents(null, null, String.format("%f,%f|%f,%f", swlong, swlat, nelong, nelat), new EventsCallback(getActivity()));
           }
       });
}
项目:hRouting_Android    文件:PathMapFragment.java   
private void zoomAndDrawLines(ArrayList<LatLng> healthiestPath,
                              ArrayList<LatLng> shortestPath) {
    final LatLngBounds.Builder builder = new LatLngBounds.Builder();
    Set<LatLng> duplicates = getDuplicates(healthiestPath, shortestPath);
    List<PolylineOptions> healthiestList = getPolyLineOptions(
            healthiestPath, duplicates, builder, true);
    List<PolylineOptions> shortestList = getPolyLineOptions(shortestPath,
            duplicates, builder, false);

    List<PolylineOptions> mergedShortest = mergePolylineOptions(shortestList);
    List<PolylineOptions> mergedHealthiest = mergePolylineOptions(healthiestList);

    // Zoom to path once the map has a layout.

    map.setOnCameraChangeListener(new OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition arg0) {
            // Move camera.
            getMap().moveCamera(
                    CameraUpdateFactory.newLatLngBounds(builder.build(), 100));
            // Remove listener to prevent position reset on camera move.
            getMap().setOnCameraChangeListener(null);
        }
    });
    addPolylinesToMap(mergedShortest);
    addPolylinesToMap(mergedHealthiest);
}
项目:referendum_1o_android    文件:GoogleMapWrapper.java   
@Override
public final void setOnCameraChangeListener(OnCameraChangeListener listener) {
    map.setOnCameraChangeListener(listener);
}
项目:mytracks    文件:MyTracksMapFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  if (savedInstanceState != null) {
    keepCurrentLocationVisible = savedInstanceState.getBoolean(
        KEEP_CURRENT_LOCATION_VISIBLE_KEY, false);
    if (keepCurrentLocationVisible) {
      Location location = (Location) savedInstanceState.getParcelable(CURRENT_LOCATION_KEY);
      if (location != null) {
        setCurrentLocation(location);
      }
    }
  }

  /*
   * At this point, after onCreateView, getMap will not return null and we can
   * initialize googleMap. However, onActivityCreated can be called multiple
   * times, e.g., when the user switches tabs. With
   * GoogleMapOptions.useViewLifecycleInFragment == false, googleMap lifecycle
   * is tied to the fragment lifecycle and the same googleMap object is
   * returned in getMap. Thus we only need to initialize googleMap once, when
   * it is null.
   */
  if (googleMap == null) {
    googleMap = getMap();
    googleMap.setMyLocationEnabled(true);

    /*
     * My Tracks needs to handle the onClick event when the my location button
     * is clicked. Currently, the API doesn't allow handling onClick event,
     * thus hiding the default my location button and providing our own.
     */
    googleMap.getUiSettings().setMyLocationButtonEnabled(false);
    googleMap.setIndoorEnabled(true);
    googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {

        @Override
      public boolean onMarkerClick(Marker marker) {
        if (isResumed()) {
          String title = marker.getTitle();
          if (title != null && title.length() > 0) {
            long id = Long.valueOf(title);
            Context context = getActivity();
            Intent intent = IntentUtils.newIntent(context, MarkerDetailActivity.class)
                .putExtra(MarkerDetailActivity.EXTRA_MARKER_ID, id);
            context.startActivity(intent);
          }
        }
        return true;
      }
    });
    googleMap.setLocationSource(new LocationSource() {

        @Override
      public void activate(OnLocationChangedListener listener) {
        onLocationChangedListener = listener;
      }

        @Override
      public void deactivate() {
        onLocationChangedListener = null;
      }
    });
    googleMap.setOnCameraChangeListener(new OnCameraChangeListener() {

        @Override
      public void onCameraChange(CameraPosition cameraPosition) {
        if (isResumed() && keepCurrentLocationVisible && currentLocation != null
            && !isLocationVisible(currentLocation)) {
          keepCurrentLocationVisible = false;
        }
      }
    });
  }
}
项目:Common-Alerting-Protocol-Compliant-Emergency-Warning-App-For-Android-Using-AMQP    文件:AffectedAreaMapActivityOnline.java   
private void setUpMap() {
    this.mMap.addCircle(new CircleOptions().center(this.center)
            .radius(this.radius).strokeColor(Color.argb(128, 0, 0, 255))
            .strokeWidth(3).fillColor(Color.argb(64, 0, 0, 255)));

    this.mMap.setOnCameraChangeListener(new OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition arg0) {
            LatLngBounds.Builder builder = LatLngBounds.builder();
            LatLngBounds bounds = builder
                    .include(
                            SphericalUtil
                                    .computeOffset(
                                            AffectedAreaMapActivityOnline.this.center,
                                            AffectedAreaMapActivityOnline.this.radius,
                                            0))
                    .include(
                            SphericalUtil
                                    .computeOffset(
                                            AffectedAreaMapActivityOnline.this.center,
                                            AffectedAreaMapActivityOnline.this.radius,
                                            90))
                    .include(
                            SphericalUtil
                                    .computeOffset(
                                            AffectedAreaMapActivityOnline.this.center,
                                            AffectedAreaMapActivityOnline.this.radius,
                                            180))
                    .include(
                            SphericalUtil
                                    .computeOffset(
                                            AffectedAreaMapActivityOnline.this.center,
                                            AffectedAreaMapActivityOnline.this.radius,
                                            270)).build();
            // Move camera.
            AffectedAreaMapActivityOnline.this.mMap
                    .moveCamera(CameraUpdateFactory.newLatLngBounds(bounds,
                            0));
            // Remove listener to prevent position reset on camera move.
            AffectedAreaMapActivityOnline.this.mMap
                    .setOnCameraChangeListener(null);
        }
    });
}
项目:HereAStory-Android    文件:GoogleMapWrapper.java   
@Override
public final void setOnCameraChangeListener(OnCameraChangeListener listener) {
    map.setOnCameraChangeListener(listener);
}
项目:mtransit-for-android    文件:GoogleMapWrapper.java   
@Override
public final void setOnCameraChangeListener(OnCameraChangeListener listener) {
    map.setOnCameraChangeListener(listener);
}
项目:MapAlarmist    文件:MainActivity.java   
private void initializeUI() {
    Switch onOffAlarm = (Switch) findViewById(R.id.switchOnOffAlarm);

    if (geoAlarm.isFirstTimeRun) {
        showWelcomeDialog();

        // Actual zoom will be performed when location service
        // is connected
        zoomOnCurrentPosition = true;

        geoAlarm.isFirstTimeRun = false;
    } else {
        if (geoAlarm.zone == null) {
            // Actual zoom will be performed when location service
            // is connected
            zoomOnCurrentPosition = true;
        } else {
            // Zoom on zone (last position)
            gMap.setOnCameraChangeListener(new OnCameraChangeListener() {
                @Override
                public void onCameraChange(CameraPosition pos) {
                    showMapLocation(geoAlarm.zone);
                    Log.d(GeoAlarmUtils.APPTAG,
                            "Showing zone saved in SharedPrefs");
                    gMap.setOnCameraChangeListener(null);
                }
            });
        }

        // set vibrate mode
        CheckBox checkboxUseVibrate = (CheckBox) findViewById(R.id.checkboxUseVibrate);
        checkboxUseVibrate.setChecked(geoAlarm.isUseVibrate);

        // set toggle button state
        onOffAlarm.setChecked(geoAlarm.isAlarmOn);
    }

    if (geoAlarm.isAlarmOn) {
        disableUI();
    }

    // Events
    onOffAlarm
            .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView,
                        boolean isChecked) {
                    MainActivity.this.switchOnOffAlarm_onChange(buttonView,
                            isChecked);
                }
            });
}
项目:referendum_1o_android    文件:IGoogleMap.java   
void setOnCameraChangeListener(OnCameraChangeListener listener);
项目:HereAStory-Android    文件:IGoogleMap.java   
void setOnCameraChangeListener(OnCameraChangeListener listener);
项目:mtransit-for-android    文件:IGoogleMap.java   
void setOnCameraChangeListener(OnCameraChangeListener listener);