Android 单击微调器选项时,在地图上放置一个标记
我有一个location活动类,带有一个由数据库值组成的微调器。我单击其中一个值,查询数据库并返回坐标。我知道我得到了正确的坐标,因为我已经在应用程序中测试了查询Android 单击微调器选项时,在地图上放置一个标记,android,google-maps,Android,Google Maps,我有一个location活动类,带有一个由数据库值组成的微调器。我单击其中一个值,查询数据库并返回坐标。我知道我得到了正确的坐标,因为我已经在应用程序中测试了查询 spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> p
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, final int i, long id) {
switch (i) {
case 0:
//remove marker
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
getSuggestedLocation(i);
//Antrim marker
break;
//Armagh marker
//Belfast marker
//Derry marker
//Down marker
//Fermanagh marker
//Tyrone marker
}
}
值得注意的是,我在onLocationResult方法中手动设置了currentLocation。但是,如果选择了某个选项,我想将值从我的db传递到该currentLocation,但我不知道如何从切换到所需方法的结果。请帮我把脑袋炸了哈哈,我一点也不喜欢安卓工作室你可以这样称呼,只需在全球范围内申报你的谷歌地图
yourGoogleMap.clear();
LatLng latlng = new LatLng(YOUR_LATITUDE, YOUR_LONGITUDE);
MarkerOptions options = new MarkerOptions()
.position(latlng)
.title(YOUR_TITLE);
yourGoogleMap.addMarker(options);
yourGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 16.0f));
yourGoogleMap.clear();
LatLng latlng = new LatLng(YOUR_LATITUDE, YOUR_LONGITUDE);
MarkerOptions options = new MarkerOptions()
.position(latlng)
.title(YOUR_TITLE);
yourGoogleMap.addMarker(options);
yourGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 16.0f));