當前位置: 首頁>>代碼示例>>Java>>正文


Java Projection.getVisibleRegion方法代碼示例

本文整理匯總了Java中com.google.android.gms.maps.Projection.getVisibleRegion方法的典型用法代碼示例。如果您正苦於以下問題:Java Projection.getVisibleRegion方法的具體用法?Java Projection.getVisibleRegion怎麽用?Java Projection.getVisibleRegion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.maps.Projection的用法示例。


在下文中一共展示了Projection.getVisibleRegion方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCameraChange

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
public void onCameraChange(CameraPosition position) {
	LatLng pos = mMarker.getPosition();
	final Projection proj = mMap.getProjection();
	final VisibleRegion vr = proj.getVisibleRegion();
	final LatLng farLeft = vr.farLeft;
	final LatLng farRight = vr.farRight;
	final LatLng nearLeft = vr.nearLeft;
	final LatLng nearRight = vr.nearRight;

	double screenLat = Math.abs(farLeft.latitude - nearRight.latitude) / 2.0;
	double screenLng = Math.abs(farLeft.longitude - nearRight.longitude) / 2.0;

	double latDiff = Math.abs(mInit.latitude - position.target.latitude);
	double lngDiff = Math.abs(mInit.longitude - position.target.longitude);

	if (latDiff > screenLat || lngDiff > screenLng) {
	    double cLat = mMap.getCameraPosition().target.latitude;
		double cLng = mMap.getCameraPosition().target.longitude;
		mInit = new LatLng(cLat, cLng);
		mMarker.position(mInit);
		mMap.clear();
		mMap.addMarker(mMarker);
	}
	
}
 
開發者ID:hilarycheng,項目名稱:xposed-gps,代碼行數:26,代碼來源:MainActivity.java

示例2: getRegionTreeList

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
public static List<Tree> getRegionTreeList(Context context, Projection projectionRigion) {

        if (dbstatic == null) {
            TreeDBHelper dbHelper = new TreeDBHelper(context);
            dbstatic = dbHelper.getReadableDatabase();
        }

        String[] projection = new String[]{TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART,
                TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN,
                COLUMN_NAME_COORDINATE_LAT,
                TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON};

        LatLngBounds bounds = projectionRigion.getVisibleRegion().latLngBounds;

        String selection = COLUMN_NAME_COORDINATE_LAT +
                " Between " + bounds.southwest.latitude +
                " And " + bounds.northeast.latitude +
                " And " + COLUMN_NAME_COORDINATE_LON +
                " Between " + bounds.southwest.longitude +
                " And " + bounds.northeast.longitude +
                " LIMIT 2000";

        Cursor cursor = dbstatic.query(TreeDBContract.TreeEntry.TABLE_NAME, projection, selection, null, null, null, null);
        List<Tree> trees = new ArrayList<>(cursor.getCount());
        while (cursor.moveToNext()) {
            Tree tree = new Tree(cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_TRAE_ART)),
                    cursor.getString(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_DANSK_NAVN)),
                    cursor.getDouble(cursor.getColumnIndex(COLUMN_NAME_COORDINATE_LAT)),
                    cursor.getDouble(cursor.getColumnIndex(TreeDBContract.TreeEntry.COLUMN_NAME_COORDINATE_LON)));
            trees.add(tree);
        }
        cursor.close();

        return trees;
    }
 
開發者ID:majornuts,項目名稱:treehugger,代碼行數:36,代碼來源:DBhandler.java

示例3: isPolygonContains

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Intersects using the Winding Number Algorithm
 * @ref http://www.nttpc.co.jp/company/r_and_d/technology/number_algorithm.html
 * @param path
 * @param point
 * @return
 */
private boolean isPolygonContains(List<LatLng> path, LatLng point) {
  int wn = 0;
  Projection projection = map.getProjection();
  VisibleRegion visibleRegion = projection.getVisibleRegion();
  LatLngBounds bounds = visibleRegion.latLngBounds;
  Point sw = projection.toScreenLocation(bounds.southwest);

  Point touchPoint = projection.toScreenLocation(point);
  touchPoint.y = sw.y - touchPoint.y;
  double vt;

  for (int i = 0; i < path.size() - 1; i++) {
    Point a = projection.toScreenLocation(path.get(i));
    a.y = sw.y - a.y;
    Point b = projection.toScreenLocation(path.get(i + 1));
    b.y = sw.y - b.y;

    if ((a.y <= touchPoint.y) && (b.y > touchPoint.y)) {
      vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y);
      if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) {
        wn++;
      }
    } else if ((a.y > touchPoint.y) && (b.y <= touchPoint.y)) {
      vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y);
      if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) {
        wn--;
      }
    }
  }

  return (wn != 0);
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:40,代碼來源:GoogleMaps.java

示例4: isPolygonContains

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Intersects using the Winding Number Algorithm
 * @ref http://www.nttpc.co.jp/company/r_and_d/technology/number_algorithm.html
 * @param path
 * @param point
 * @return
 */
private boolean isPolygonContains(List<LatLng> path, LatLng point) {
  int wn = 0;
  Projection projection = map.getProjection();
  VisibleRegion visibleRegion = projection.getVisibleRegion();
  LatLngBounds bounds = visibleRegion.latLngBounds;
  Point sw = projection.toScreenLocation(bounds.southwest);
  
  Point touchPoint = projection.toScreenLocation(point);
  touchPoint.y = sw.y - touchPoint.y;
  double vt;
  
  for (int i = 0; i < path.size() - 1; i++) {
    Point a = projection.toScreenLocation(path.get(i));
    a.y = sw.y - a.y;
    Point b = projection.toScreenLocation(path.get(i + 1));
    b.y = sw.y - b.y;
    
    if ((a.y <= touchPoint.y) && (b.y > touchPoint.y)) {
      vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y);
      if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) {
        wn++;
      }
    } else if ((a.y > touchPoint.y) && (b.y <= touchPoint.y)) {
      vt = ((double)touchPoint.y - (double)a.y) / ((double)b.y - (double)a.y);
      if (touchPoint.x < ((double)a.x + (vt * ((double)b.x - (double)a.x)))) {
        wn--;
      }
    }
  }
  
  return (wn != 0);
}
 
開發者ID:neo4art,項目名稱:neo4art,代碼行數:40,代碼來源:GoogleMaps.java

示例5: ClustersBuilder

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
ClustersBuilder(Projection projection, Options options, ArrayList<ClusterPoint> initialClusteredPoints) {
	this.options = options;

	this.projectionRef = new WeakReference<Projection>(projection);
	this.visibleRegionRef = new WeakReference<VisibleRegion>(projection.getVisibleRegion());

	if (initialClusteredPoints != null) {
		addRelevantInitialInputPoints(initialClusteredPoints);
	}
}
 
開發者ID:twotoasters,項目名稱:clusterkraf,代碼行數:11,代碼來源:ClustersBuilder.java


注:本文中的com.google.android.gms.maps.Projection.getVisibleRegion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。