packagecom.cmcc.locationaddress_gps_sdk_test;
importcom.cmcc.location_gps_sdk.ILocationDetail;
importcom.cmcc.location_gps_sdk.ILocationManger;
importcom.cmcc.location_gps_sdk.IReferenceAddress;
importcom.cmcc.location_gps_sdk.SDKManager;
importcom.example.locationaddress_gps_sdk_test.R;
importandroid.os.Bundle;
importandroid.util.Log;
importandroid.app.Activity;
publicclassMainActivityextendsActivity {
privateILocationManger iLtionMInstance;
@Override
protectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
iLtionMInstance = SDKManager.getILocationMangerInstance(getApplicationContext());
iLtionMInstance.getCurrentLocation(iLocatDE);
setContentView(R.layout.activity_main);
testLocationAddress();
}
//拿到定位的城市
ILocationDetail iLocatDE =newILocationDetail() {
publicvoidgetLocationDetial(String city) {
Log.i("tag","定位的城市"+city);
}
};
//傳遞至轉(zhuǎn)化成經(jīng)緯度
privatevoidtestLocationAddress() {
//循環(huán)地址
for(inti=0;i
{
String addressName = strArray[i];
Log.i("tag","地址"+addressName);
iLtionMInstance.setDisList(addressName);
}
iLtionMInstance.getLocationByAdrdress(referCB);
}
//根據(jù)地址轉(zhuǎn)換經(jīng)緯度算出距離
IReferenceAddress referCB =newIReferenceAddress() {
@Override
publicvoidgetIReferenceAddress(doubledistance) {
Log.i("distance","距離-->"+distance);
}
};
String[] strArray={"北京市西城區(qū)宣武門西大2號(hào)","北京市西城區(qū)宣武門西大街28號(hào)","北京市朝陽區(qū)慧忠北里309-6號(hào)第5大道精品休閑購物廣場B2層","北京市海淀區(qū)北安河路68號(hào)",
"北京市昌平區(qū)回龍觀北店嘉園26號(hào)","北京市大興區(qū)北程莊金星路"," 北京市大興區(qū)天寶園五里一區(qū)22號(hào)","北京市海淀區(qū)西三旗橋東","北京市朝陽區(qū)安定路甲3號(hào)"," 北京市海淀區(qū)上地十街10號(hào)",
"北京市朝陽區(qū)慧忠北里309-6號(hào)第5大道精品休閑購物廣場B2層","北京市海淀區(qū)怡美家園","北京市海淀區(qū)交通大學(xué)路","北京市海淀區(qū)交通大學(xué)路1號(hào)院","北京市豐臺(tái)區(qū)北京西站南路168號(hào)513室",
"朝陽區(qū)崔各莊鄉(xiāng)大望京村"," 昌平科技園區(qū)星火街9號(hào)","北京市昌平區(qū)立湯路186號(hào)龍德廣場五層","昌平區(qū)興壽鎮(zhèn)東營村上東路和上西路交叉口"," 北京市朝陽區(qū)將臺(tái)鄉(xiāng)尚君廟28號(hào)","北京市昌平區(qū)南口鎮(zhèn)馬坊村",
"北京市昌平區(qū)于新莊路","北京市昌平區(qū)北七家鎮(zhèn)政府街東","北京市西城區(qū)真武廟二條5號(hào)","北京西城區(qū)永安路175號(hào)"," 西城區(qū)真武廟二條5號(hào)","北京市西城區(qū)復(fù)興門外大街19號(hào)樓"};
}
細(xì)節(jié)說明下載可以到這里查看www.oschina.net/code/snippet_2244406_48028