我使用Google Maps
在地图上添加标记。我的位置坐标,即LatLng
值存储在SQLite
数据库中。我可以为所有这些添加标记。但我的问题是当两个标记位于完全相同的位置或LatLng
只有一个可见我。我无法看到对方,否则我碰到了他们。所以请帮我区分相同位置的标记。我的代码是
private void viewAll() {
addTollGate();
try{
String allQuery="select rowid _id,* from vehiclesTable";
Cursor c4=db.rawQuery(allQuery,null);
if (c4.getCount()>0){
while (c4.moveToNext()){
strNumbers=c4.getString(c4.getColumnIndex("deviceNo"));
strVname=c4.getString(c4.getColumnIndex("vehicleName"));
try{
String strQuery="select rowid _id,* from logTable where _id=(select MAX(_id) from logTable where deviceNo='"+strNumbers+"')";
Cursor c5=db.rawQuery(strQuery,null);
if (c5.getCount()>0){
while (c5.moveToNext()) {
String allLatLng = c5.getString(c5.getColumnIndex("log"));
final String allDate = c5.getString(c5.getColumnIndex("date"));
String[] strArray1 = allLatLng.split(",");
double lat = Double.parseDouble(strArray1[0]);
double lng = Double.parseDouble(strArray1[1]);
String strTime = strArray1[2];
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
String dateToday = sdf.format(date);
Date oneHrBefore=new Date(System.currentTimeMillis()-3600*1000);
String strCurrent=dateToday+" "+strTime+":00";
SimpleDateFormat format=new SimpleDateFormat("dd-MMM-yyyy kk:mm:ss");
Date lastKnown=new Date();
try {
lastKnown=format.parse(strCurrent);
}catch (ParseException e){
e.printStackTrace();
}
if (dateToday.equals(allDate)) {
if (lastKnown.after(oneHrBefore)&&lastKnown.before(date)){
IconGenerator iconGenerator = new IconGenerator(this);
iconGenerator.setColor(getResources().getColor(R.color.myBlue1));
iconGenerator.setTextAppearance(R.style.iconGenText);
bmp = iconGenerator.makeIcon(strVname);
}else {
IconGenerator iconGenerator = new IconGenerator(this);
iconGenerator.setColor(getResources().getColor(R.color.myGreen));
iconGenerator.setTextAppearance(R.style.iconGenText);
bmp = iconGenerator.makeIcon(strVname);
}
} else{
IconGenerator iconGenerator = new IconGenerator(this);
iconGenerator.setColor(getResources().getColor(R.color.myRed));
iconGenerator.setTextAppearance(R.style.iconGenText);
bmp = iconGenerator.makeIcon(strVname);
}
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bmp);
markers = googleMap.addMarker(new MarkerOptions().position(new LatLng(lat, lng)).icon(bitmapDescriptor).title(strVname).snippet("Known @" + strTime + "," + allDate));
builder.include(new LatLng(lat, lng));
bounds = builder.build();
googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
}
}
}catch (SQLiteException e){
e.printStackTrace();
}
}
}
}catch (SQLiteException e){
e.printStackTrace();
}
}
答案 0 :(得分:0)
switch (strDsType.ToUpper())
{
case GridColumnData.DSType_SQL:
case GridColumnData.DSType_Oracle:
}
public static class GridColumnData
{
public const string DSType_SQL= "ABC Instrumentation";
}
bitmapDescriptor:你必须创建多个位图并在同一位置制作标记