我有一个ArrayList具有lat和long属性的自定义对象.
我已设法在地图上放置标记.我想要的是能够在地图加载时放大这些标记.
我在下面尝试的内容导致应用程序崩溃.
这是加载地图的代码:
public void getBridgeData() {
db = new DbHelperClass(this);
bridges = db.getAllBridges();
DecimalFormat dc = new DecimalFormat("#.000");
Builder builder = new LatLngBounds.Builder();
for (int i= 0;i<bridges.size();i++) {
Bridge b= (Bridge)bridges.get(i);
double lati= b.getLatitude();
double longo= b.getLongitude();
double reflat= b.getReflat();
double reflong= b.getReflong();
LatLng start = new LatLng(reflat,reflong);
LatLng end = new LatLng(lati,longo);
GeneralUtils uts = new GeneralUtils();
double ch= uts.calculateDistance(start, end);
String chainage = dc.format(ch);
String mysnipet = "Location:" + b.getRoadname() + " " + …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,当选择菜单项删除时,代码会执行,但如果是代码的一部分,也会跳转到else.
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
int menuItemIndex = item.getItemId();
final AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
//final int pos = menuInfo.position;
final String menuItemName =menuItems[menuItemIndex];
if(menuItemName.equals("Delete"))
{
try{
int pos = menuInfo.position;
Locations l= (Locations)locations.get(pos);
int id= l.get_id();
if( db.deleteLocation(id))
{
locations.remove(pos);
s.remove(pos);
arrayAdapter.notifyDataSetChanged();
}else
{
Toast.makeText(this,"Can not delet a location with apartment blocks",Toast.LENGTH_LONG).show();
}
}catch(Exception e)
{
e.printStackTrace();
}
}else if((menuItemName.equals("View Receipts")));
{
// get an extral to pass to the intent
int …Run Code Online (Sandbox Code Playgroud)