use of org.osmdroid.bonuspack.kml.KmlTrack in project osmbonuspack by MKergall.
the class MapActivity method recordCurrentLocationInTrack.
void recordCurrentLocationInTrack(String trackId, String trackName, GeoPoint currentLocation) {
// Find the KML track in the current KML structure - and create it if necessary:
KmlTrack t;
KmlFeature f = mKmlDocument.mKmlRoot.findFeatureId(trackId, false);
if (f == null)
t = createTrack(trackId, trackName);
else if (!(f instanceof KmlPlacemark))
// id already defined but is not a PlaceMark
return;
else {
KmlPlacemark p = (KmlPlacemark) f;
if (!(p.mGeometry instanceof KmlTrack))
// id already defined but is not a Track
return;
else
t = (KmlTrack) p.mGeometry;
}
// TODO check if current location is really different from last point of the track
// record in the track the current location at current time:
t.add(currentLocation, new Date());
// refresh KML:
updateUIWithKml();
}
use of org.osmdroid.bonuspack.kml.KmlTrack in project osmbonuspack by MKergall.
the class MapActivity method createTrack.
KmlTrack createTrack(String id, String name) {
KmlTrack t = new KmlTrack();
KmlPlacemark p = new KmlPlacemark();
p.mId = id;
p.mName = name;
p.mGeometry = t;
mKmlDocument.mKmlRoot.add(p);
// set a color to this track by creating a style:
Style s = new Style();
int color;
try {
color = Integer.parseInt(id);
color = color % TrackColor.length;
color = TrackColor[color];
} catch (NumberFormatException e) {
color = Color.GREEN - 0x20000000;
}
s.mLineStyle = new LineStyle(color, 8.0f);
p.mStyle = mKmlDocument.addStyle(s);
return t;
}
use of org.osmdroid.bonuspack.kml.KmlTrack in project osmbonuspack by MKergall.
the class KmlListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
KmlFeature item = (KmlFeature) getItem(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) viewGroup.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.kml_list_item, null);
}
TextView itemText = (TextView) convertView.findViewById(R.id.listItemTxt);
itemText.setText(item.mName);
// Handle checkbox:
/*
CheckBox checkBoxIsVisible = (CheckBox)convertView.findViewById(R.id.listItemCheckbox);
checkBoxIsVisible.setChecked(mRoot.mItems.get(position).mVisibility);
if (checkBoxIsVisible != null) {
checkBoxIsVisible.setOnClickListener(new OnClickListener(){
@Override public void onClick(View view) {
int position = (Integer)view.getTag();
KmlFeature item = mRoot.mItems.get(position);
item.mVisibility = ((CheckBox)view).isChecked();
}
});
checkBoxIsVisible.setTag(position);
}
*/
ImageView img = (ImageView) convertView.findViewById(R.id.listItemImg);
if (item instanceof KmlFolder) {
img.setImageResource(R.drawable.moreinfo_arrow);
} else if (item instanceof KmlPlacemark) {
KmlGeometry geometry = ((KmlPlacemark) item).mGeometry;
if (geometry instanceof KmlPoint)
img.setImageResource(R.drawable.marker_kml_point);
else if (geometry instanceof KmlLineString)
img.setImageResource(R.drawable.kml_icon_linestring);
else if (geometry instanceof KmlPolygon)
img.setImageResource(R.drawable.kml_icon_polygon);
else if (geometry instanceof KmlMultiGeometry)
img.setImageResource(R.drawable.kml_icon_multigeometry);
else if (geometry instanceof KmlTrack)
img.setImageResource(R.drawable.kml_icon_gxtrack);
else
img.setImageDrawable(null);
} else if (item instanceof KmlGroundOverlay) {
img.setImageResource(R.drawable.kml_icon_groundoverlay);
} else
img.setImageDrawable(null);
return convertView;
}
Aggregations