这是我的地图课...
public class Mapa extends FragmentActivity implements LocationListener {
public GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mapa);
获取 Google Play 可用性状态
int status =GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
显示状态 if(status!=ConnectionResult.SUCCESS){ // Google Play 服务不可用
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}else {
获取对 SupportMapFragment 的引用
SupportMapFragment fm = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
从片段中获取 GoogleMap 对象
map = fm.getMap();
启用 Google Map 的 MyLocation 图层
map.setMyLocationEnabled(true);
从系统服务 LOCATION_SERVICE 获取 LocationManager 对象
LocationManager locationManager = (LocationManager)
getSystemService(LOCATION_SERVICE);
创建条件对象以检索提供者
Criteria criteria = new Criteria();
获得最佳提供商的名称
String provider = locationManager.getBestProvider(criteria, true);
获取当前位置
Location location = locationManager.getLastKnownLocation(provider);
if(location!=null){
onLocationChanged(location);
}
locationManager.requestLocationUpdates(provider, 20000, 0, this);
}
}
public void onLocationChanged(Location location) {
TextView tvLocation = (TextView) findViewById(R.id.tv_location);
获取当前位置的纬度
double latitude = location.getLatitude();
获取当前位置的经度
double longitude = location.getLongitude();
为当前位置创建一个 LatLng 对象
LatLng latLng = new LatLng(latitude, longitude);
在谷歌地图中显示当前位置
map.moveCamera(CameraUpdateFactory.newLatLng(latLng));
放大谷歌地图
map.animateCamera(CameraUpdateFactory.zoomTo(15));
在 TextView tv_location 中设置纬度和经度
tvLocation.setText("Latitude:" + latitude + ", Longitude:"+ longitude );
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
这是我的arraylist课程
public void getPontos(View view) {
String codigo;
codigo = linhaList.get(spinner.getSelectedItemPosition()).getCodigo();
new WebServiceGetPontosLinha().execute(codigo);
}
private class WebServiceGetPontosLinha extends
AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(MainActivity.this, "",
getResources().getText(R.string.connecting), true, false);
}
@Override
protected Void doInBackground(String... params) {
WebServiceConsumer webServiceConsumer = new WebServiceConsumer(
MainActivity.this);
pontoList = webServiceConsumer.getPontos(params[0]);
return null;
}
@Override
protected void onPostExecute(Void result) {
progressDialog.dismiss();
pontoArrayAdapter = new ArrayAdapter<PontosLinhas>(
MainActivity.this,
android.R.layout.simple_spinner_dropdown_item, pontoList);
spinner1.setAdapter(pontoArrayAdapter);
}
}
如何像图像一样在地图上绘制微调器的内容?