Tabnine Logo
Projection
Code IndexAdd Tabnine to your IDE (free)

How to use
Projection
in
com.google.android.gms.maps

Best Java code snippets using com.google.android.gms.maps.Projection (Showing top 20 results out of 315)

Refine searchRefine arrow

  • Paint
  • Point
  • Canvas
  • MapView
  • GeoPoint
origin: airbnb/AirMapView

@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());
}
origin: airbnb/AirMapView

@Override public void getScreenLocation(LatLng latLng, OnLatLngScreenLocationCallback callback) {
 callback.onLatLngScreenLocationReady(googleMap.getProjection().toScreenLocation(latLng));
}
origin: stackoverflow.com

 @Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
    Projection proj = mapView.getProjection();
    GeoPoint loc = new GeoPoint(geo.getLat(), geo.getLng());

    Point point = new Point();
    proj.toPixels(loc, point);
    float rad = (float) (proj.metersToEquatorPixels(radius) * (1 / Math.cos(Math.toRadians(loc.getLatitudeE6() / 1000000))));

    Paint circle = new Paint();
    circle.setColor(colour);
    circle.setAlpha(30);
    circle.setAntiAlias(true);
    circle.setStyle(Style.FILL);

    canvas.drawCircle(point.x, point.y, rad, circle);

    super.draw(canvas, mapView, shadow);

}
origin: stackoverflow.com

    GeoPoint gp2 = route[i + 1];
    polyPaint.setAntiAlias(true);
    Point point = new Point();
    projection.toPixels(gp1, point);
      Point point2 = new Point();
      projection.toPixels(gp2, point2);
          + mRadius);
      offscreencanvas.drawOval(oval, polyPaint);
      Point point2 = new Point();
      projection.toPixels(gp2, point2);
      path.lineTo(point2.x, point2.y);
      Point point2 = new Point();
      projection.toPixels(gp2, point2);
      path.lineTo(point2.x, point2.y);
mapStartPosition = projection.fromPixels(0, 0);
Point offsetPt = new Point();
proj.toPixels(mapStartPosition, offsetPt);
origin: stackoverflow.com

point = new GeoPoint((int)(latitude),(int)(longitude));
OverlayItem overlayitem = new OverlayItem(point, "Radius", String.format("%.0f m", accuracy));
itemizedoverlay.addOverlay(overlayitem);
int latSpan, longSpan, rightEdge, leftEdge, topEdge, bottomEdge;
boolean setIsIn, userIsIn;
center = new GeoPoint((point.getLatitudeE6() + userLocationOverlay.getMyLocation().getLatitudeE6())/2,(point.getLongitudeE6() + point.getLongitudeE6())/2);
centerLatitude = center.getLatitudeE6();
centerLongitude = center.getLongitudeE6();
   Point pt = new Point();
   projection.toPixels(point ,pt);
   float circleRadius = projection.metersToEquatorPixels((float)accuracy);
   innerCirclePaint = new Paint();
   innerCirclePaint.setColor(Color.BLUE);
   innerCirclePaint.setAlpha(25);
   innerCirclePaint.setAntiAlias(true);
   CirclePaint.setAntiAlias(true);
   canvas.drawCircle((float)pt.x, (float)pt.y, circleRadius, innerCirclePaint);
origin: stackoverflow.com

 private void drawCircleAtPoint(GeoPoint point, Canvas canvas, MapView mapView) {

    Projection projection = mapView.getProjection();        
    Point pt2 = new Point();
    projection.toPixels(point, pt2);
// method that is used to conver the radius to pixel that takes input the radius and draw it on the coresponding pixels 
    float circleRadius = projection.metersToEquatorPixels(radius) * (1/ FloatMath.cos((float) Math.toRadians(MapController.mylat)));
    Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    Paint rectangle=new Paint(Paint.ANTI_ALIAS_FLAG);
    Log.d("Circular Radius", ""+circleRadius+"             "+radius);

    circlePaint.setColor(0x99000000);
    circlePaint.setStyle(Style.STROKE);
    canvas.drawCircle((float)pt2.x, (float)pt2.y, circleRadius, circlePaint);




  }
origin: stackoverflow.com

 Projection projection = mapView.getProjection();
Point center = projection.toPixels(new GeoPoint(yourLat * E6, yourLong * E6), null);
float radius = projection.metersToEquatorPixels(radiusInMeters);
canvas.draw(center.x, center.y, radius, new Paint());
origin: stackoverflow.com

Point p = new Point();
projection.toPixels(point11, p);
p.offset(0, -(bubble.getMeasuredHeight() / 2));
GeoPoint target = projection.fromPixels(p.x, p.y);
origin: stackoverflow.com

 public static void panMap (int x, int y, MapView map) {
  Point ptPixels = new Point();
  GeoPoint geoPt = map.getMapCenter();
  Projection projection = map.getProjection();
  projection.toPixels(geoPt, ptPixels);
  ptPixels.x += x;
  ptPixels.y += y;
  geoPt = projection.fromPixels(ptPixels.x, ptPixels.y);
  map.getController().animateTo(geoPt);
}
origin: stackoverflow.com

 @Override
public void draw(Canvas canvas, MapView mapview, boolean shadow) {
  super.draw(canvas, mapview, shadow);
  if(shadow) return;
  if(mp.getPoints() == null || mp.getPoints().size() < 2) return;

  Projection projection = mapview.getProjection();
  int lonSpanNew = projection.fromPixels(0,mapview.getHeight()/2).getLongitudeE6() - 
      projection.fromPixels(mapview.getWidth(),mapview.getHeight()/2).getLongitudeE6();
  if(lonSpanNew != pathInitialLonSpan)
    pathBuild();
  else{ //check if path need to be offset
    projection.toPixels(mp.getPoints().get(0), p1);
    if(p1.x != pathInitialPoint.x || p1.y != pathInitialPoint.y){
      path.offset(p1.x - pathInitialPoint.x, p1.y - pathInitialPoint.y);
      pathInitialPoint.x = p1.x;
      pathInitialPoint.y = p1.y;
    }

  }
  canvas.drawPath(path, paint); 
}
origin: stackoverflow.com

Point mapCenter = projection.toPixels(getMapCenter(), null);
Point newCenter = new Point(mapCenter);
if (!newCenter.equals(mapCenter)) {
 getController().animateTo(projection.fromPixels(newCenter.x, newCenter.y));
origin: mg6maciej/android-maps-extensions

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;
}
origin: stackoverflow.com

final long start = SystemClock.uptimeMillis();
Projection proj = map.getProjection();
Point startPoint = proj.toPixels(marker.getPosition(), null);
final IGeoPoint startGeoPoint = proj.fromPixels(startPoint.x, startPoint.y);
final long duration = 500;
final Interpolator interpolator = new LinearInterpolator();
    long elapsed = SystemClock.uptimeMillis() - start;
    float t = interpolator.getInterpolation((float) elapsed / duration);
    double lng = t * toPosition.getLongitude() + (1 - t) * startGeoPoint.getLongitude();
    double lat = t * toPosition.getLatitude() + (1 - t) * startGeoPoint.getLatitude();
    marker.setPosition(new GeoPoint(lat, lng));
    if (t < 1.0) {
      handler.postDelayed(this, 15);
origin: mg6maciej/android-maps-extensions

@Override
public VisibleRegion getVisibleRegion() {
  return projection.getVisibleRegion();
}
origin: stackoverflow.com

 Projection projection = map.getProjection();
projection.toPixels(geoPointBefore, pt);
geoPointAfter = projection.fromPixels(pt.x, pt.y);

int diffLatitude  = geoPointBefore.getLatitudeE6()  - geoPointAfter.getLatitudeE6();
int diffLongitude = geoPointBefore.getLongitudeE6() - geoPointAfter.getLongitudeE6();
...
...
...
// Add the difference to GeoPoint objects after conversion `fromPixels`
origin: stackoverflow.com

Projection projection = mapView.getProjection();
Point pt = new Point();
GeoPoint geo = new GeoPoint((int) (mLat *1e6), (int)(mLon * 1e6));
projection.toPixels(geo ,pt);
float circleRadius = projection.metersToEquatorPixels(mRadius);
innerCirclePaint = new Paint();
innerCirclePaint.setColor(Color.BLUE);
innerCirclePaint.setAlpha(25);
innerCirclePaint.setAntiAlias(true);
innerCirclePaint.setStyle(Paint.Style.FILL);
canvas.drawCircle((float)pt.x, (float)pt.y, circleRadius, innerCirclePaint);
origin: stackoverflow.com

Point p = new Point();
projection.toPixels(result.getPoint(), p);
p.offset(0, -(bubble.getMeasuredHeight() / 2));
GeoPoint target = projection.fromPixels(p.x, p.y);
origin: stackoverflow.com

 @Override
public void draw(Canvas canvas, MapView mapview, boolean shadow) {
  super.draw(canvas, mapview, shadow);
  if(shadow) return;
  if(mp.getPoints() == null || mp.getPoints().size() < 2) return;

  Projection projection = mapview.getProjection();
  int lonSpanNew = projection.fromPixels(0,mapview.getHeight()/2).getLongitudeE6() - 
      projection.fromPixels(mapview.getWidth(),mapview.getHeight()/2).getLongitudeE6();
  if(lonSpanNew != pathInitialLonSpan)
    pathBuild();
  else{ //check if path need to be offset
    projection.toPixels(mp.getPoints().get(0), p1);
    if(p1.x != pathInitialPoint.x || p1.y != pathInitialPoint.y){
      path.offset(p1.x - pathInitialPoint.x, p1.y - pathInitialPoint.y);
      pathInitialPoint.x = p1.x;
      pathInitialPoint.y = p1.y;
    }

  }
  canvas.drawPath(path, paint); 
}
origin: Bhoomika06/Styled-Map-Pager

@Override
public void onPageSelected(int position) {
  MyLocation location = latLngsArrayList.get(position);
  Point mappoint = map.getProjection().toScreenLocation(
      new LatLng(location.getLatitude(), location.getLongitude()));
  mappoint.set(mappoint.x, mappoint.y - 30);
  map.animateCamera(CameraUpdateFactory.newLatLng(map.getProjection().fromScreenLocation(mappoint)));
  customMap.addSelectedCustomPin(position);
}
origin: car2go/AnyMaps

@Override
public VisibleRegion getVisibleRegion() {
  return AnyMapAdapter.adapt(projection.getVisibleRegion());
}
com.google.android.gms.mapsProjection

Most used methods

  • fromScreenLocation
  • toScreenLocation
  • getVisibleRegion
  • fromPixels
  • metersToEquatorPixels
  • toPixels

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now