Yer api öğrenmeye başlıyorum. Bir etkinlik oluşturmayı başardım ve düğmeyi tıklattığınızda yer api konum seçiciyi bir haritayla oluşturur. Benim sorunum, kodlanmış bir LatLangBounds ile bunu yapabilirim, haritayı oluşturduğumda şu anki konumumdan başlamaktır. Bunu haritalar api kullanarak yaptım ama bu yerlerde api kafam karıştı.Güncel konumunuza google'ın android yerler API nasıl yüklenir
private static final int PLACE_PICKER_REQUEST = 1;
private TextView mName;
private TextView mAddress;
private TextView mAttributions;
private static final LatLngBounds BOUNDS_HARD_CODED_LOCATION = new LatLngBounds(
new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_picker);
/**
* not part of places api standard code to add back function to action bar
*/
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mName = (TextView) findViewById(R.id.textView);
mAddress = (TextView) findViewById(R.id.textView2);
mAttributions = (TextView) findViewById(R.id.textView3);
Button pickerButton = (Button) findViewById(R.id.pickerButton);
pickerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
PlacePicker.IntentBuilder intentBuilder =
new PlacePicker.IntentBuilder();
intentBuilder.setLatLngBounds(BOUNDS_HARD_CODED_LOCATION);
Intent intent = intentBuilder.build(PlacePickerActivity.this);
startActivityForResult(intent, PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException
| GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
});
}