0
Google지도에서 길게 터치하여 latLng을 얻는 Android 애플리케이션을 제작 중입니다. 여기 안드로이드에서지도의 중심점을 얻는 방법은 무엇입니까?
코드입니다 : 내가해야 할 것은 내가lat = map.getCameraPosition().target;
을 사용했다 내가 위도의 값을 토스트 할 때, 그것은
0.0 토스트입니다
public class MainActivitytut extends FragmentActivity{
GoogleMap googleMap;
MarkerOptions markerOptions;
LatLng latLng;
private TextView myAddress;
String lat;
TextView txtmapinfo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maintut);
//onBackPressed();
SupportMapFragment supportMapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
// Getting a reference to the map
googleMap = supportMapFragment.getMap();
// Setting a click event handler for the map
googleMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng arg0) {
// Getting the Latitude and Longitude of the touched location
latLng = arg0;
lat = latLng.toString();
// Toast.makeText(getApplicationContext(), lat,
// Toast.LENGTH_LONG).show();
// getMyLocationAddress();
// Clears the previously touched position
googleMap.clear();
// Animating to the touched position
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
// Creating a marker
markerOptions = new MarkerOptions();
// Setting the position for the marker
markerOptions.position(latLng);
// Placing a marker on the touched position
googleMap.addMarker(markerOptions);
// Adding Marker on the touched location with address
new ReverseGeocodingTask(getBaseContext()).execute(latLng);
}
});
}
protected void putExtra(String string, CharSequence text) {
// TODO Auto-generated method stub
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
// present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
그 때지도에게 위도와 경도 변화를 강타에 토스트. 지도가로드 한 후 getCameraPosition 호출 할 때까지
OK 덕분에, 내가 시도하고 다시 당신에게 얻을 수 있습니다. – Test123
이 센터 카메오 자리로 마크를 설정하는 방법을 알려주십시오. 제발 도와주세요. 나는 안드로이드를 처음 접한다. – Test123
@Sonam 꽤 쉽게. 내 업데이트 답변을 참조하십시오. – Simas