0

在我的所有其他项目中,我能够在任何 MapView 对象上调用 getProjection()。由于某种原因,这个项目有所不同......是因为我使用新的 APIv2 来进行谷歌地图吗?有任何想法吗?

package com.example.proximitystuff;

import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.Projection;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.maps.MapActivity;

import android.app.Activity;
import android.app.Fragment;
import android.graphics.Point;
import android.os.Bundle;
import android.view.MotionEvent;


public class MyMapActivity extends MapActivity {

    private MapView map =null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_map);

        MapView map = (MapView)findViewById(R.id.map);

        //this line of code wont work... says projection cannot be resolved or is not a field
        Projection projection= map.getProjection;

        }


    @Override   
    public boolean onTouchEvent(MotionEvent event){
            int x = (int)event.getX();
            int y = (int)event.getY();
            Point p = new Point(x, y);
            switch (event.getAction()){
                case MotionEvent.ACTION_DOWN: //todo
                case MotionEvent.ACTION_MOVE: //todo
                case MotionEvent.ACTION_UP:   //todo

            }
            return false;       
        }


    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}
4

1 回答 1

3

改成:

GoogleMap googleMap = map.getMap();
Projection projection = googleMap.getProjection();

也替换MapActivityActivity和删除isRouteDisplayed。然后在此处开始阅读 Google Maps Android API v2:https ://developers.google.com/maps/documentation/android/start

于 2013-06-18T20:56:52.687 回答