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


Java Projection.toScreenLocation方法代碼示例

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


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

示例1: isPointOnTheLine

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Intersection for non-geodesic line
 * @ref http://movingahead.seesaa.net/article/299962216.html
 * @ref http://www.softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm#Line-Plane
 *
 * @param points
 * @param point
 * @return
 */
private boolean isPointOnTheLine(List<LatLng> points, LatLng point) {
  double Sx, Sy;
  Projection projection = map.getProjection();
  Point p0, p1, touchPoint;
  touchPoint = projection.toScreenLocation(point);

  p0 = projection.toScreenLocation(points.get(0));
  for (int i = 1; i < points.size(); i++) {
    p1 = projection.toScreenLocation(points.get(i));
    Sx = ((double)touchPoint.x - (double)p0.x) / ((double)p1.x - (double)p0.x);
    Sy = ((double)touchPoint.y - (double)p0.y) / ((double)p1.y - (double)p0.y);
    if (Math.abs(Sx - Sy) < 0.05 && Sx < 1 && Sx > 0) {
      return true;
    }
    p0 = p1;
  }
  return false;
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:28,代碼來源:GoogleMaps.java

示例2: drawHole

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
protected void drawHole(final Bitmap bitmap, final Projection projection,
                        final List<RichPoint> points2Draw,
                        final int paddingLeft, final int paddingTop,
                        final int paddingRight, final int paddingBottom) {
    Canvas canvas = new Canvas(bitmap);
    Path linePath = new Path();
    boolean firstPoint = true;
    for (RichPoint point : points2Draw) {
        LatLng position = point.getPosition();
        if (position != null) {
            Point bmpPoint = projection.toScreenLocation(position);
            int bmpPointX = bmpPoint.x;
            int bmpPointY = bmpPoint.y + paddingBottom / 2 - paddingTop / 2;

            if (firstPoint) {
                linePath.moveTo(bmpPointX, bmpPointY);
                firstPoint = false;
            } else {
                linePath.lineTo(bmpPointX, bmpPointY);
            }
        }
    }

    Paint paint = getDefaultHolePaint();
    canvas.drawPath(linePath, paint);
}
 
開發者ID:antoniocarlon,項目名稱:richmaps,代碼行數:27,代碼來源:RichPolygon.java

示例3: zoomMapToMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Zooms the map to a marker, so that it will be above
 * the MapAdditionFragment.
 *
 * @param marker A Marker from a GoogleMap.
 */
public void zoomMapToMarker(Marker marker) {
    //move camera to display marker above the mapAddtionFragment
    Projection projection = mGoogleMap.getProjection();

    LatLng markerLatLng = new LatLng(marker.getPosition().latitude,
            marker.getPosition().longitude);
    Point markerScreenPosition = projection.toScreenLocation(markerLatLng);
    Point pointHalfScreenAbove = new Point(markerScreenPosition.x,
            markerScreenPosition.y + (this.getResources().getDisplayMetrics().heightPixels / 5));

    LatLng aboveMarkerLatLng = projection
            .fromScreenLocation(pointHalfScreenAbove);

    marker.showInfoWindow();
    CameraUpdate center = CameraUpdateFactory.newLatLng(aboveMarkerLatLng);
    mGoogleMap.animateCamera(center);
}
 
開發者ID:xamoom,項目名稱:xamoom-pingeborg-android,代碼行數:24,代碼來源:MapFragment.java

示例4: isPointOnTheLine

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Intersection for non-geodesic line
 * @ref http://movingahead.seesaa.net/article/299962216.html
 * @ref http://www.softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm#Line-Plane
 * 
 * @param points
 * @param point
 * @return
 */
private boolean isPointOnTheLine(List<LatLng> points, LatLng point) {
  double Sx, Sy;
  Projection projection = map.getProjection();
  Point p0, p1, touchPoint;
  touchPoint = projection.toScreenLocation(point);

  p0 = projection.toScreenLocation(points.get(0));
  for (int i = 1; i < points.size(); i++) {
    p1 = projection.toScreenLocation(points.get(i));
    Sx = ((double)touchPoint.x - (double)p0.x) / ((double)p1.x - (double)p0.x);
    Sy = ((double)touchPoint.y - (double)p0.y) / ((double)p1.y - (double)p0.y);
    if (Math.abs(Sx - Sy) < 0.05 && Sx < 1 && Sx > 0) {
      return true;
    }
    p0 = p1;
  }
  return false;
}
 
開發者ID:neo4art,項目名稱:neo4art,代碼行數:28,代碼來源:GoogleMaps.java

示例5: animateMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
public void animateMarker(final Marker marker, final LatLng toPosition) {
	final Handler handler = new Handler();
	final long start = SystemClock.uptimeMillis();
	Projection proj = map.getProjection();
	Point startPoint = proj.toScreenLocation(marker.getPosition());
	final LatLng startLatLng = proj.fromScreenLocation(startPoint);
	final long duration = 500;

	final Interpolator interpolator = new LinearInterpolator();

	handler.post(new Runnable() {
		@Override
		public void run() {
			long elapsed = SystemClock.uptimeMillis() - start;
			float t = interpolator.getInterpolation((float) elapsed / duration);
			double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude;
			double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude;
			marker.setPosition(new LatLng(lat, lng));

			if (t < 1.0) {
				// Post again 16ms later.
				handler.postDelayed(this, 16);
			}
		}
	});
}
 
開發者ID:larseknu,項目名稱:android_programmering_2014,代碼行數:27,代碼來源:MainActivity.java

示例6: ptsGeoToPixels

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private void ptsGeoToPixels() {
    _points.clear();
    int j = 0;
    LatLng ptGeo = null;
    double longitude = 0;
    double latitude = 0;
    Projection projection = map.getProjection();
    android.graphics.Point ptPixels = null;
    for (j = 0; j < _pointsGeo.size(); j++) {
        ptGeo = _pointsGeo.get(j);
        longitude = ptGeo.longitude;
        latitude = ptGeo.longitude;
        ptPixels = projection.toScreenLocation(ptGeo);
        _points.add(new Point(ptPixels.x, ptPixels.y));
    }
}
 
開發者ID:missioncommand,項目名稱:mil-sym-android,代碼行數:17,代碼來源:MyView.java

示例7: showInfoWindow

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private void showInfoWindow(Cluster cluster) {
  	Marker m = cluster.get(0);
  	// Save the current camera so we can restore it later
  	previousCameraPosition = map.getCameraPosition();
  	
  	// Get the screen-space position of the Cluster
  	int yoffset = markerSize / 2;
Projection proj = map.getProjection();
      Point p = proj.toScreenLocation(m.getPosition());
      int markerX = p.x;
      int markerY = p.y - yoffset;

// Get the position where we'll ultimately show the marker & spotlight
final Point newMarkerPos = getZoneCenter(m);

// Animate the spotlight from the current marker position to its final position
showSpotlight(markerX, markerY, newMarkerPos.x, newMarkerPos.y);

// Position the selected marker in the top, right, bottom, or left zone
final CameraUpdate camUpdate = calculateCameraChange(newMarkerPos.x, newMarkerPos.y, 
		markerX, markerY);
map.animateCamera(camUpdate, 400, null);
// Show the popup list next to the marker
showInfo(newMarkerPos.x + markerSize/2, newMarkerPos.y + yoffset, cluster);
  }
 
開發者ID:souvik16,項目名稱:google-maps-blog-android-sample-code,代碼行數:26,代碼來源:ClustersAreListsActivity.java

示例8: onMapClick

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
@Override
public void onMapClick(LatLng latLng) {
    Projection projection = mMap.getProjection();
    Point point = projection.toScreenLocation(latLng);

    Rect rect = new Rect();
    bottomSheet.getGlobalVisibleRect(rect);
    if (!rect.contains(point.x, point.y)) {
        Utils.logD(LOG_TAG, "outside bottom sheet");
        mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
    }
}
 
開發者ID:cahergil,項目名稱:Farmacias,代碼行數:13,代碼來源:MapTabFragment.java

示例9: buildClickLatLngBoundingBox

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Build a lat lng bounding box using the click location, map view, map, and screen percentage tolerance.
 * The bounding box can be used to query for features that were clicked
 *
 * @param latLng                click location
 * @param view                  map view
 * @param map                   map
 * @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature
 *                              on the screen must be to be included in a click query
 * @return lat lng bounding box
 */
public static LatLngBoundingBox buildClickLatLngBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) {

    // Get the screen width and height a click occurs from a feature
    int width = (int) Math.round(view.getWidth() * screenClickPercentage);
    int height = (int) Math.round(view.getHeight() * screenClickPercentage);

    // Get the screen click location
    Projection projection = map.getProjection();
    android.graphics.Point clickLocation = projection.toScreenLocation(latLng);

    // Get the screen click locations in each width or height direction
    android.graphics.Point left = new android.graphics.Point(clickLocation);
    android.graphics.Point up = new android.graphics.Point(clickLocation);
    android.graphics.Point right = new android.graphics.Point(clickLocation);
    android.graphics.Point down = new android.graphics.Point(clickLocation);
    left.offset(-width, 0);
    up.offset(0, -height);
    right.offset(width, 0);
    down.offset(0, height);

    // Get the coordinates of the bounding box points
    LatLng leftCoordinate = projection.fromScreenLocation(left);
    LatLng upCoordinate = projection.fromScreenLocation(up);
    LatLng rightCoordinate = projection.fromScreenLocation(right);
    LatLng downCoordinate = projection.fromScreenLocation(down);

    LatLngBoundingBox latLngBoundingBox = new LatLngBoundingBox(leftCoordinate, upCoordinate, rightCoordinate, downCoordinate);

    return latLngBoundingBox;
}
 
開發者ID:ngageoint,項目名稱:geopackage-android-map,代碼行數:42,代碼來源:MapUtils.java

示例10: convertToCoords

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private Coordinate[] convertToCoords(List<LatLng> latLngs, Projection projection){
  int count = latLngs.size();
  Coordinate[] coords = new Coordinate[count];
  int index = 0;
  for(LatLng latLng : latLngs){
    Point p = projection.toScreenLocation(latLng);
    coords[index] = new Coordinate(p.x, p.y);
      index++;
  }

  return coords;
}
 
開發者ID:fiskurgit,項目名稱:KortidTol,代碼行數:13,代碼來源:ConcaveHull.java

示例11: 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

示例12: setDropAnimation_

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private void setDropAnimation_(final Marker marker, final PluginAsyncInterface callback) {
  final Handler handler = new Handler();
  final long startTime = SystemClock.uptimeMillis();
  final long duration = 100;
  
  final Projection proj = this.map.getProjection();
  final LatLng markerLatLng = marker.getPosition();
  final Point markerPoint = proj.toScreenLocation(markerLatLng);
  final Point startPoint = new Point(markerPoint.x, 0);
  
  final Interpolator interpolator = new LinearInterpolator();

  handler.post(new Runnable() {
    @Override
    public void run() {
      LatLng startLatLng = proj.fromScreenLocation(startPoint);
      long elapsed = SystemClock.uptimeMillis() - startTime;
      float t = interpolator.getInterpolation((float) elapsed / duration);
      double lng = t * markerLatLng.longitude + (1 - t) * startLatLng.longitude;
      double lat = t * markerLatLng.latitude + (1 - t) * startLatLng.latitude;
      marker.setPosition(new LatLng(lat, lng));
      if (t < 1.0) {
        // Post again 16ms later.
        handler.postDelayed(this, 16);
      } else {
        marker.setPosition(markerLatLng);
        callback.onPostExecute(marker);
      }
    }
  });
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:32,代碼來源:PluginMarker.java

示例13: setBounceAnimation_

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Bounce animation
 * http://android-er.blogspot.com/2013/01/implement-bouncing-marker-for-google.html
 */
private void setBounceAnimation_(final Marker marker, final PluginAsyncInterface callback) {
  final Handler handler = new Handler();
  final long startTime = SystemClock.uptimeMillis();
  final long duration = 2000;
  
  final Projection proj = this.map.getProjection();
  final LatLng markerLatLng = marker.getPosition();
  final Point startPoint = proj.toScreenLocation(markerLatLng);
  startPoint.offset(0, -200);
  
  final Interpolator interpolator = new BounceInterpolator();

  handler.post(new Runnable() {
    @Override
    public void run() {
      LatLng startLatLng = proj.fromScreenLocation(startPoint);
      long elapsed = SystemClock.uptimeMillis() - startTime;
      float t = interpolator.getInterpolation((float) elapsed / duration);
      double lng = t * markerLatLng.longitude + (1 - t) * startLatLng.longitude;
      double lat = t * markerLatLng.latitude + (1 - t) * startLatLng.latitude;
      marker.setPosition(new LatLng(lat, lng));

      if (t < 1.0) {
        // Post again 16ms later.
        handler.postDelayed(this, 16);
      } else {
        marker.setPosition(markerLatLng);
        callback.onPostExecute(marker);
      }
    }
  });
}
 
開發者ID:AdrianBZG,項目名稱:PhoneChat,代碼行數:37,代碼來源:PluginMarker.java

示例14: loadPath

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
public void loadPath(LatLng fromLatlng, LatLng toLatlng, GoogleMap map) {
  isArc = true;
  Projection projection = mProjectionHelper.getProjection();
  this.zoomAnchor = mProjectionHelper.getCameraPosition().zoom;
  mProjectionHelper.setCenterlatLng(projection
      .fromScreenLocation(new Point(getWidth()/2, getHeight()/2)));
  onCameraMove(map);

  if (fromLatlng == null || toLatlng == null) return;

  mRoutePath.rewind();
  mArcLoadingPath.rewind();

  pickUpPoint = projection.toScreenLocation(fromLatlng);
  dropPoint = projection.toScreenLocation(toLatlng);

  mArcLoadingPath = Util.createCurvedPath(pickUpPoint.x, pickUpPoint.y, dropPoint.x, dropPoint.y, 180);

  PathMeasure pathMeasure = new PathMeasure(mArcLoadingPath, false);
  mAnimationArcHelper.length = pathMeasure.getLength();
  mAnimationArcHelper.dashValue = new float[] { mAnimationArcHelper.length, mAnimationArcHelper.length };

  new Handler(Looper.getMainLooper()).post(new Runnable() {
    @Override
    public void run() {
      mAnimationArcHelper.init();
      mAnimationArcHelper.play();
    }
  });

  isPathSetup = true;
}
 
開發者ID:amalChandran,項目名稱:trail-android,代碼行數:33,代碼來源:RouteOverlayView.java

示例15: animateMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
static public void animateMarker(final Marker marker, final LatLng toPosition, GoogleMap googleMap) {
  final Handler handler = new Handler();
  final long start = SystemClock.uptimeMillis();
  Projection projection = googleMap.getProjection();
  Point startPoint = projection.toScreenLocation(marker.getPosition());
  final LatLng startLatLng = projection.fromScreenLocation(startPoint);
  final long duration = 500;

  final Interpolator interpolator = new LinearInterpolator();

  handler.post(new Runnable() {
    @Override
    public void run() {
      long elapsed = SystemClock.uptimeMillis() - start;
      float t = interpolator.getInterpolation((float) elapsed
          / duration);
      double lng = t * toPosition.longitude + (1 - t)
          * startLatLng.longitude;
      double lat = t * toPosition.latitude + (1 - t)
          * startLatLng.latitude;
      marker.setPosition(new LatLng(lat, lng));

      if (t < 1.0) {
        // Post again 16ms later.
        handler.postDelayed(this, 16);
      } else {
        marker.setVisible(true);
      }
    }
  });
}
 
開發者ID:eleith,項目名稱:calchoochoo,代碼行數:32,代碼來源:MapUtils.java


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