@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (m_IsFirstOpen) {
m_IsFirstOpen = false;
return;
}
MyToast.showMyToast(DrawerActivity.this, "选择了" + m_spSection.getSelectedItem().toString(), Toast.LENGTH_SHORT);
try {
if (_dsInfo != null) {
_dsInfo.dispose();
}
m_MapControl.getMap().close();
_dsInfo = new DatasourceConnectionInfo();
String section = ServerConfig.getMapMap().get(m_spSection.getSelectedItem().toString());
if (section == null) return;
_dsInfo.setServer(ServerConfig.URL_CHECK_SECTION + section);
LogUtils.i("MapUrl=-------------", ServerConfig.URL_CHECK_SECTION + section);
_dsInfo.setEngineType(EngineType.Rest);
_dsInfo.setAlias(section); //标识 每个标段,要设置不一样的标识
_ds = m_workspace.getDatasources().open(_dsInfo);
if (_ds != null) {
m_MapControl.getMap().getLayers().add(_ds.getDatasets().get(0), true);
String mapName = m_MapControl.getMap().getName();
LogUtils.i("MapName=-------------", mapName);
m_MapControl.getMap().refresh();
hideLoading();
大神好:如上代码,我在spinner里设置了每个数据源的URL,同时设置了标识Alias,然后打开,每項点击第一次的时候可以正常打开,然后第二次选到了,提示数据源别名已被占用,原因是设置标识重复了吗,该如何处理这一步呢?