WEB开发网
开发学院手机开发Android 开发 Android 数据库与MapView总结 阅读

Android 数据库与MapView总结

 2010-11-05 00:54:34 来源:WEB开发网   
核心提示:allRestaurantCal.add(c.getString(3));}if(allRestaurantID.size()>0){Random generator = new Random();int intThrowIndex = generator.nextInt(allRestaurantID.size

allRestaurantCal.add(c.getString(3));

}

if(allRestaurantID.size()>0)

{

Random generator = new Random();

int intThrowIndex = generator.nextInt(allRestaurantID.size());

mTextView01.setText

(

allRestaurantName.get(intThrowIndex)+" "+

allRestaurantAddress.get(intThrowIndex)+" "+

allRestaurantCal.get(intThrowIndex)+

getResources().getText(R.string.str_cal)

);

/* 以地址查询地理坐标 */

GeoPoint gp =

getGeoByAddress(allRestaurantAddress.get(intThrowIndex));

if(gp==null)

{

/* 地址无法反查为GeoPoint时 */

mMapView01.setVisibility(MapView.GONE);

}

else

{

/* 更新MapView地图 */

mMapView01.setVisibility(MapView.VISIBLE);

showImageOverlay(gp);

refreshMapViewByGeoPoint

(

getGeoByAddress(allRestaurantAddress.get(intThrowIndex)),

mMapView01, intZoomLevel, true

);

}

}

else

{

/* 数据库无记录 */

}

}

private GeoPoint getGeoByAddress(String strSearchAddress)

{

GeoPoint gp = null;

try

{

if(strSearchAddress!="")

{

Geocoder mGeocoder01 =

new Geocoder(EX10_06_04.this, Locale.getDefault());

List

lstAddress =

mGeocoder01.getFromLocationName(strSearchAddress, 1);

if (!lstAddress.isEmpty())

{

Address adsLocation = lstAddress.get(0);

/* 1E6 = 1000000*/

double geoLatitude = adsLocation.getLatitude()*1E6;

double geoLongitude = adsLocation.getLongitude()*1E6;

gp = new GeoPoint((int) geoLatitude, (int) geoLongitude);

}

上一页  16 17 18 19 20 21 22 23 24 25 26  下一页

Tags:Android 数据库 MapView

编辑录入:coldstar [复制链接] [打 印]
赞助商链接