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


Java Projection.fromScreenLocation方法代碼示例

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


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

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

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

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

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

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

示例6: projectPathIntoMap

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
@Override
public List<LatLong> projectPathIntoMap(List<LatLong> path) {
    List<LatLong> coords = new ArrayList<LatLong>();
    Projection projection = getMap().getProjection();

    for (LatLong point : path) {
        LatLng coord = projection.fromScreenLocation(new Point((int) point
                .getLatitude(), (int) point.getLongitude()));
        coords.add(MapUtils.latLngToCoord(coord));
    }

    return coords;
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:14,代碼來源:GoogleMapFragment.java

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

示例8: animateMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Make the marker fly towards toPosition on map. Sets the position of the
 * MarkerOption point to toPosition.
 * 
 * @param marker
 * @param toPosition
 * @param point
 * @param deltaHeight
 */
public void animateMarker(final Marker marker, final LatLng toPosition,
      final MarkerOptions point, final String[] results, int deltaHeight) {
   final Handler handler = new Handler();
   final long start = SystemClock.uptimeMillis();
   Projection proj = mMap.getProjection();
   Point startPoint = proj.toScreenLocation(marker.getPosition());

   final LatLng startLatLng = proj.fromScreenLocation(startPoint);
   final long duration = 500 + (deltaHeight > 0 ? deltaHeight : 0);
   final Interpolator interpolator = new LinearInterpolator();
   handler.post(new Runnable() {
      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 {
            point.position(toPosition);
            marker.setPosition(toPosition);
            marker.remove();
            insertIntoDatabase(results);
         }
      }
   });
   if (PreferenceManager.getDefaultSharedPreferences(mainActivity)
         .getBoolean("automovecamera", false))
      mMap.animateCamera(CameraUpdateFactory.newLatLng(toPosition));
}
 
開發者ID:safesoftware,項目名稱:fme-apps-android,代碼行數:44,代碼來源:SendLocationAndUpdateMapTask.java

示例9: animateMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
/**
 * Make the marker fly towards toPosition on map. Sets the position of the
 * MarkerOption point to toPosition.
 * 
 * @param marker
 * @param toPosition
 * @param point
 */
public void animateMarker(final Marker marker, final LatLng toPosition,
		final MarkerOptions point) {
	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() {
		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 {
				point.position(toPosition);
				marker.setPosition(toPosition);
				marker.setVisible(true);
				mainActivity.addMarkerToList(point);
			}
		}
	});
	map.animateCamera(CameraUpdateFactory.newLatLng(toPosition));
}
 
開發者ID:safesoftware,項目名稱:fme-apps-android,代碼行數:41,代碼來源:SendLocationAndUpdateMapTask.java

示例10: projectPathIntoMap

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
@Override
public List<LatLong> projectPathIntoMap(List<LatLong> path) {
    List<LatLong> coords = new ArrayList<LatLong>();
    Projection projection = getMap().getProjection();

    for (LatLong point : path) {
        LatLng coord = projection.fromScreenLocation(new Point((int) point
                .getLatitude(), (int) point.getLongitude()));
        coords.add(DroneHelper.LatLngToCoord(coord));
    }

    return coords;
}
 
開發者ID:sommishra,項目名稱:DroidPlanner-Tower,代碼行數:14,代碼來源:GoogleMapFragment.java

示例11: calculateDistanceBetweenMarkers

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private double calculateDistanceBetweenMarkers() {
    Projection projection = map.getProjection();
    Point point = projection.toScreenLocation(new LatLng(0.0, 0.0));
    point.x += getResources().getDimensionPixelSize(R.dimen.distance_between_markers);
    LatLng nextPosition = projection.fromScreenLocation(point);
    return nextPosition.longitude;
}
 
開發者ID:benbek,項目名稱:HereAStory-Android,代碼行數:8,代碼來源:MapActivity_bo.java

示例12: updateMyLocationMarkerAnimated

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
void updateMyLocationMarkerAnimated(@NonNull final LatLng target) {
        if (gMap == null) return;
        final long duration = 250;
        handler = new Handler();
        final long start = SystemClock.uptimeMillis();
        Projection proj = gMap.getProjection();

        Point startPoint = proj.toScreenLocation(myLocationMarker.getPosition());
        final LatLng startLatLng = proj.fromScreenLocation(startPoint);

        if (startPoint == null || startLatLng == null) {
            Log.w(TAG,
                  new RuntimeException(String.format(
                          ">startPoint == null? %s >startLatLng == null? %s >myLocationMarker.getPosition %s",
                          startPoint == null,
                          startLatLng == null,
                          myLocationMarker == null ? null : myLocationMarker.getPosition())));
            return;
        }

//        final LinearInterpolator interpolator = new LinearInterpolator();
        handler.post(new Runnable() {
            @Override
            public void run() {
                long elapsed = SystemClock.uptimeMillis() - start;
//                float t = interpolator.getInterpolation((float) elapsed / duration);
                float t = Math.min(elapsed / duration, 1f);
                double lng = t * target.longitude + (1 - t) * startLatLng.longitude;
                double lat = t * target.latitude + (1 - t) * startLatLng.latitude;
                myLocationMarker.setPosition(new LatLng(lat, lng));
                if (t < 1.0) {
                    // Post again 10ms later.
                    handler.postDelayed(this, 10);
                }
            }
        });
    }
 
開發者ID:carlosefonseca,項目名稱:CEFCommon,代碼行數:38,代碼來源:MapHelper.java

示例13: animateMarker

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
public void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    Projection proj = mMap.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);
            } else {
                if (hideMarker) {
                    marker.setVisible(false);
                } else {
                    marker.setVisible(true);
                }
            }
        }
    });
}
 
開發者ID:codebutler,項目名稱:busdrone-android,代碼行數:36,代碼來源:MainActivity.java

示例14: drawYMetric

import com.google.android.gms.maps.Projection; //導入方法依賴的package包/類
private void drawYMetric(Canvas canvas, Paint textPaint, Paint barPaint) {
    Projection projection = mMap.getProjection();

    if (projection != null) {
        Location locationP1 = new Location("ScaleBar location p1");
        Location locationP2 = new Location("ScaleBar location p2");

        LatLng p1 = projection.fromScreenLocation(new Point(getWidth() / 2,
                (int) ((getHeight() / 2) - (mYdpi / 2))));
        LatLng p2 = projection.fromScreenLocation(new Point(getWidth() / 2,
                (int) ((getHeight() / 2) + (mYdpi / 2))));

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

        float yMetersPerInch = locationP1.distanceTo(locationP2);

        if (mIsLongitudeBar) {
            String yMsg = scaleBarLengthText(yMetersPerInch);
            Rect yTextRect = new Rect();
            textPaint.getTextBounds(yMsg, 0, yMsg.length(), yTextRect);

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

            canvas.drawRect(mXOffset, mYOffset, mXOffset + mLineWidth, mYOffset + mYdpi, barPaint);
            canvas.drawRect(mXOffset, mYOffset + mYdpi, mXOffset + yTextRect.height() +
                    mLineWidth + textSpacing, mYOffset + mYdpi + mLineWidth, barPaint);

            if (!mIsLatitudeBar) {
                canvas.drawRect(mXOffset, mYOffset, mXOffset + yTextRect.height() +
                        mLineWidth + textSpacing, mYOffset + mLineWidth, barPaint);
            }

            float x = mXOffset + yTextRect.height() + mLineWidth + textSpacing;
            float y = mYOffset + mYdpi / 2 + yTextRect.width() / 2;

            canvas.rotate(-90, x, y);
            canvas.drawText(yMsg, x, y + textSpacing, textPaint);
        }
    }
}
 
開發者ID:typebrook,項目名稱:FiveMinsMore,代碼行數:44,代碼來源:ScaleBar.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) {
        int point1, point2;
        point1 = (int) (((getWidth() / 2) - (mXdpi / 2)));
        point2 =  (int) (getHeight() / 2);
        LatLng p1 = projection.fromScreenLocation(
                new Point(point1, point2));

        int point3, point4;
        point3 = (int) (((getWidth() / 2) + (mXdpi / 2)));
        point4 =  (int) (getHeight() / 2);
        LatLng p2 = projection.fromScreenLocation(
                new Point(point3, point4));

        Location locationP1 = new Location(SCALEBAR_LOCATION_PART_1);
        Location locationP2 = new Location(SCALEBAR_LOCATION_PART_2);

        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, mIsImperial, mIsNautical);
            Rect xTextRect = new Rect();
            textPaint.getTextBounds(xMsg, 0, xMsg.length(), xTextRect);

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

            if(drawLine) {
                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) {
                if(drawLine) {
                    canvas.drawRect(mXOffset, mYOffset, mXOffset + mLineWidth, mYOffset +
                            xTextRect.height() + mLineWidth + textSpacing, barPaint);
                }
            }
            if(drawNumbers) {
                canvas.drawText(xMsg, (mXOffset + mXdpi / 2 - xTextRect.width() / 2),
                        (mYOffset + xTextRect.height() + mLineWidth + textSpacing), textPaint);
            }
        }
    }
}
 
開發者ID:PGMacDesign,項目名稱:PGMacTips,代碼行數:54,代碼來源:ScaleBar.java


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