本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
}
});
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}