Code example for Projection

Methods: fromScreenLocation

0
package org.g_okuyama.transform.area; 
 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.Projection; 
import com.google.android.gms.maps.model.LatLng; 
 
import android.app.AlertDialog; 
import android.content.Context; 
import android.content.DialogInterface; 
import android.graphics.Bitmap; 
import android.graphics.Canvas; 
import android.graphics.Color; 
import android.graphics.Paint; 
import android.graphics.Path; 
import android.graphics.Point; 
import android.graphics.PorterDuff.Mode; 
import android.location.Location; 
import android.os.Handler; 
import android.util.AttributeSet; 
import android.util.Log; 
import android.view.MotionEvent; 
import android.view.View; 
 
public class OverlayView extends View {
    private static final boolean DEBUG = false;
     
    Context mContext;
     
    Paint mPaint;
     
    private Bitmap  mBitmap;
    private Canvas  mCanvas;
    private Path    mPath;
    private Paint   mBitmapPaint;
 
    private GoogleMap mMap;
    //�n�_ 
    private Location mStart;
    //�I�_ 
    private Location mEnd;
    //�O���̈ʒu 
    private Location mPrev;
    private Projection mProjection;
    //���� 
    private double mDistance = 0.0;
    //1�s�N�Z���̋��� 
    private float m1PxDist = 0.0f;
    //�ʐ� 
    private double mArea = 0.0;
    //1�M�ŕ`�����Ă��邩�̔����t���O 
    private boolean mFlag = false;
    //�G���[�t���O(�G���[�_�C�A���O�\�������̂�OK���������Ȃ������Ƃ��p) 
    private boolean mErrFlag = false;
     
    public OverlayView(GoogleMap map, Context context) {
        super(context);
        mContext = context;
        mMap = map;
         
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setColor(0xFFFF0000);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(10);
         
        mPath = new Path();
        mBitmapPaint = new Paint(Paint.DITHER_FLAG);
         
        mProjection = mMap.getProjection();
        //1�s�N�Z���̋����𑪒肷�� 
        LatLng p1 = mProjection.fromScreenLocation(new Point(0, 0));
        Location l1 = new Location("p1");
        l1.setLatitude(p1.latitude);
        l1.setLongitude(p1.longitude);
        LatLng p2 = mProjection.fromScreenLocation(new Point(0, 1));
        Location l2 = new Location("p2");
        l2.setLatitude(p2.latitude);
        l2.setLongitude(p2.longitude);
        m1PxDist = l1.distanceTo(l2);
        if(DEBUG){