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