0
在我所有其他能夠在任何MapView對象上調用getProjection()的項目中。這個項目由於某種原因是不同的...是因爲我使用新的APIv2的谷歌地圖?有任何想法嗎?getProjection無法解析爲字段。 API V2
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;
}
}
這很好。你能解釋一下,你如何知道需要一個GoogleMap對象,而不像舊的Maps API那樣需要MapView? –
@adamkim從文檔:https://developers.google.com/maps/documentation/android/map –