当前位置: 首页>>代码示例>>Java>>正文


Java OnCameraChangeListener类代码示例

本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.OnCameraChangeListener的典型用法代码示例。如果您正苦于以下问题:Java OnCameraChangeListener类的具体用法?Java OnCameraChangeListener怎么用?Java OnCameraChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OnCameraChangeListener类属于com.google.android.gms.maps.GoogleMap包,在下文中一共展示了OnCameraChangeListener类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpMapIfNeeded

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
/**
 * 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);
                }
              });
        }
    }
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:39,代码来源:VisibleRegionDemoActivity.java

示例2: initMap

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
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();
	}
}
 
开发者ID:twotoasters,项目名称:clusterkraf,代码行数:23,代码来源:SampleActivity.java

示例3: zoomAndDrawLines

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
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);
}
 
开发者ID:dhasenfratz,项目名称:hRouting_Android,代码行数:28,代码来源:PathMapFragment.java

示例4: setOnCameraChangeListener

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
private void setOnCameraChangeListener() {
	mGoogleMap.setOnCameraChangeListener(new OnCameraChangeListener() {
		@Override
		public void onCameraChange(CameraPosition pos) {
			mCurrentZoom = pos.zoom;
		}
	});
}
 
开发者ID:godstale,项目名称:Arduino-Navigator,代码行数:9,代码来源:GMapControl.java

示例5: onViewCreated

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
@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()));
           }
       });
}
 
开发者ID:nmcgill,项目名称:kluster-android,代码行数:33,代码来源:EventMapFragment.java

示例6: setOnCameraChangeListener

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
@Override
public final void setOnCameraChangeListener(OnCameraChangeListener listener) {
    map.setOnCameraChangeListener(listener);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:5,代码来源:GoogleMapWrapper.java

示例7: onActivityCreated

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
@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;
        }
      }
    });
  }
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:76,代码来源:MyTracksMapFragment.java

示例8: setUpMap

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
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);
		}
	});
}
 
开发者ID:pratyaym,项目名称:Common-Alerting-Protocol-Compliant-Emergency-Warning-App-For-Android-Using-AMQP,代码行数:45,代码来源:AffectedAreaMapActivityOnline.java

示例9: setOnCameraChangeListener

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
@Override
public final void setOnCameraChangeListener(OnCameraChangeListener listener) {
	map.setOnCameraChangeListener(listener);
}
 
开发者ID:mtransitapps,项目名称:mtransit-for-android,代码行数:5,代码来源:GoogleMapWrapper.java

示例10: initializeUI

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
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);
				}
			});
}
 
开发者ID:gvellut,项目名称:MapAlarmist,代码行数:53,代码来源:MainActivity.java

示例11: setOnCameraChangeListener

import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; //导入依赖的package包/类
void setOnCameraChangeListener(OnCameraChangeListener listener); 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:2,代码来源:IGoogleMap.java


注:本文中的com.google.android.gms.maps.GoogleMap.OnCameraChangeListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。