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


Java Projection类代码示例

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


Projection类属于com.google.android.gms.maps包,在下文中一共展示了Projection类的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: drawScaleBarPicture

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
private void drawScaleBarPicture(Canvas canvas) {
    // We want the scale bar to be as long as the closest round-number miles/kilometers
    // to 1-inch at the latitude at the current center of the screen.

    Projection projection = mMap.getProjection();

    if (projection == null) {
        return;
    }

    final Paint barPaint = new Paint();
    barPaint.setColor(Color.BLACK);
    barPaint.setAntiAlias(true);
    barPaint.setStrokeWidth(mLineWidth);

    final Paint textPaint = new Paint();
    textPaint.setColor(Color.BLACK);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(dmu.getScalablePixelTextSize(TEXT_SIZE_BASE));

    drawXMetric(canvas, textPaint, barPaint);

    drawYMetric(canvas, textPaint, barPaint);
}
 
开发者ID:PGMacDesign,项目名称:PGMacTips,代码行数:25,代码来源:ScaleBar.java

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

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

示例5: getMapScreenBounds

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
@Override public void getMapScreenBounds(OnMapBoundsCallback callback) {
  final Projection projection = googleMap.getProjection();
  int hOffset = getResources().getDimensionPixelOffset(R.dimen.map_horizontal_padding);
  int vOffset = getResources().getDimensionPixelOffset(R.dimen.map_vertical_padding);

  LatLngBounds.Builder builder = LatLngBounds.builder();
  builder.include(projection.fromScreenLocation(new Point(hOffset, vOffset))); // top-left
  builder.include(projection.fromScreenLocation(
      new Point(getView().getWidth() - hOffset, vOffset))); // top-right
  builder.include(projection.fromScreenLocation(
      new Point(hOffset, getView().getHeight() - vOffset))); // bottom-left
  builder.include(projection.fromScreenLocation(new Point(getView().getWidth() - hOffset,
      getView().getHeight() - vOffset))); // bottom-right

  callback.onMapBoundsReady(builder.build());
}
 
开发者ID:airbnb,项目名称:AirMapView,代码行数:17,代码来源:NativeGoogleMapFragment.java

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

示例7: putLatLngAtScreenCoords

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
protected void putLatLngAtScreenCoords(LatLng loc, Point target) {
    LatLng curTarget = mMap.getCameraPosition().target;
    Projection projection = mMap.getProjection();
    double selectLat = projection.fromScreenLocation(target).latitude;

    double targetLongitude = loc.longitude;
    double targetLatitude = loc.latitude + (curTarget.latitude - selectLat);

    LatLng latLngTarget = new LatLng(targetLatitude, targetLongitude);
    float zoom = mMap.getCameraPosition().zoom;

    CameraPosition movement = new CameraPosition.Builder()
            .target(latLngTarget)
            .zoom(zoom)
            .tilt(zoomToTilt(zoom))
            .build();

    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(movement), 500, null);
}
 
开发者ID:opus-ua,项目名称:beacon-frontend,代码行数:20,代码来源:ConstrainedCameraMap.java

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

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

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

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

示例12: add

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
void add(ClusterPoint currentClusterPoint) {
	Projection projection = projectionRef != null ? projectionRef.get() : null;
	if (currentClusterPoint != null && projection != null) {
		boolean animated = false;
		if (previousClusterPoints != null) {
			for (ClusterPoint previousClusterPoint : previousClusterPoints) {
				for (InputPoint previousInputPoint : previousClusterPoint.getPointsInCluster()) {
					if (currentClusterPoint.containsInputPoint(previousInputPoint)) {
						AnimatedTransition transition = getTransition(previousInputPoint);
						if (transition != null) {
							transition.addOriginClusterRelevantInputPoint(previousInputPoint);
						} else {
							transition = new AnimatedTransition(projection, previousClusterPoint, previousInputPoint, currentClusterPoint);
							animatedTransitions.add(transition);
							animated = true;
						}
					}
				}
			}
		}
		if (animated == false) {
			stationaryTransitions.add(currentClusterPoint);
		}
	}
}
 
开发者ID:twotoasters,项目名称:clusterkraf,代码行数:26,代码来源:ClusterTransitions.java

示例13: build

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
ArrayList<ClusterPoint> build() {
	Projection projection = getProjection();
	ArrayList<ClusterPoint> clusteredPoints = null;
	if (projection != null) {
		clusteredPoints = new ArrayList<ClusterPoint>(relevantInputPointsList.size());
		for (InputPoint point : relevantInputPointsList) {
			boolean addedToExistingCluster = false;
			for (ClusterPoint clusterPoint : clusteredPoints) {
				if (clusterPoint.getPixelDistanceFrom(point) <= options.getPixelDistanceToJoinCluster()) {
					clusterPoint.add(point);
					addedToExistingCluster = true;
					break;
				}
			}
			if (addedToExistingCluster == false) {
				clusteredPoints.add(new ClusterPoint(point, projection, false));
			}
		}
	}
	return clusteredPoints;
}
 
开发者ID:twotoasters,项目名称:clusterkraf,代码行数:22,代码来源:ClustersBuilder.java

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

示例15: drawXMetric

import com.google.android.gms.maps.Projection; //导入依赖的package包/类
private void drawXMetric(Canvas canvas, Paint textPaint, Paint barPaint) {
    Projection projection = mMap.getProjection();

    if (projection != null) {
        LatLng p1 = projection.fromScreenLocation(new Point((int) ((getWidth() / 2) - (mXdpi / 2)), getHeight() / 2));
        LatLng p2 = projection.fromScreenLocation(new Point((int) ((getWidth() / 2) + (mXdpi / 2)), getHeight() / 2));

        Location locationP1 = new Location("ScaleBar location p1");
        Location locationP2 = new Location("ScaleBar location p2");

        locationP1.setLatitude(p1.latitude);
        locationP2.setLatitude(p2.latitude);
        locationP1.setLongitude(p1.longitude);
        locationP2.setLongitude(p2.longitude);

        float xMetersPerInch = locationP1.distanceTo(locationP2);

        if (mIsLatitudeBar) {
            String xMsg = scaleBarLengthText(xMetersPerInch);
            Rect xTextRect = new Rect();
            textPaint.getTextBounds(xMsg, 0, xMsg.length(), xTextRect);

            int textSpacing = (int) (xTextRect.height() / 5.0);

            canvas.drawRect(mXOffset, mYOffset, mXOffset + mXdpi, mYOffset + mLineWidth, barPaint);
            canvas.drawRect(mXOffset + mXdpi, mYOffset, mXOffset + mXdpi + mLineWidth, mYOffset +
                    xTextRect.height() + mLineWidth + textSpacing, barPaint);

            if (!mIsLongitudeBar) {
                canvas.drawRect(mXOffset, mYOffset, mXOffset + mLineWidth, mYOffset +
                        xTextRect.height() + mLineWidth + textSpacing, barPaint);
            }
            canvas.drawText(xMsg, (mXOffset + mXdpi / 2 - xTextRect.width() / 2),
                    (mYOffset + xTextRect.height() + mLineWidth + textSpacing), textPaint);
        }
    }
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:38,代码来源:ScaleBar.java


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