Itemized Overlays...Not drawing a collection but refreshing????

by Scott » Fri, 23 Apr 2010 08:05:14 GMT


Sponsored Links
 'm trying to write code that draws accuracy circles around a gps
location based on a time param. I have no problem setting up the GPS,
or of calculating how to draw the circles...What's been killing me is
that the Overlays always overwrite one another...So I can never have
more than one circle...I've looked at all the examples and tutorials
online but they seem to be obsessed with putting in icons or with
Drawing from some database or array...If I understood correctly I
should be able to do itemizedoverlays and just draw as i go without
having to track each readout in an array....HELP WHAT AM I DOING
WRONG? PS This code also crashes if I touch the map now.

MY CLASS
public class HelloItemizedOverlay extends ItemizedOverlay {
private List items;
private Drawable marker;
public HelloItemizedOverlay() {
super(null);
items = new ArrayList();
}
@Override
protected OverlayItem createItem(int index) {
return (OverlayItem)items.get(index);
}
@Override
public int size() {
return items.size();
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
super.draw(canvas, mapView, shadow);
if (TempLat > 0) {
Point center = new Point();
Point left = new Point();
Point screenPts = new Point();
Projection projection = mapView.getProjection();
float[] result = new float[1];
Location.distanceBetween(TempLat, TempLon, TempLat,
TempLon +1, result);
float longitudeLineDistance = result[0];
GeoPoint leftGeo = new GeoPoint((int)(TempLat*1e6),(int)
((TempLon-TempAccy/longitudeLineDistance)*1e6));
projection.toPixels(leftGeo, left);
projection.toPixels(p, center);
int radius = center.x - left.x;
accuracyPaint.setAntiAlias(true);
accuracyPaint.setStrokeWidth(2.0f);
accuracyPaint.setColor(0xff6666ff);
accuracyPaint.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius,
accuracyPaint);
accuracyPaint.setColor(0x186666ff);
accuracyPaint.setStyle(Style.FILL);
canvas.drawCircle(center.x, center.y, radius,
accuracyPaint);
}
}
public void addItem(OverlayItem item) {
items.add(item);
populate();
}
}

MY ONCREATE INITIALIZATION CALL

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.myGMap);
LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);
View zoomView = mapView.getZoomControls();
mapView.setSatellite(true);
zoomLayout.addView(zoomView,
new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);
mc = mapView.getController();
mc.setZoom(1;
accuracyPaint = new Paint();
overlay = new HelloItemizedOverlay();
......

MY ONLOCATIONCHANGED EVENT

public void onLocationChanged(Location location) {
MSGSTXT.setText("Location Found...");
TempTime = location.getTime();
TempLat = location.getLatitude();
TempLon = location.getLongitude();
TempAccy = location.getAccuracy();
TempSpeed = location.getSpeed();
TempBear = location.getBearing();
TempAlt = location.getAltitude();
p = new GeoPoint(
(int) (TempLat * 1E6),
(int



Other Threads

1. Regarding coding standards for GPL license device drivers code



Why do you think that the GPL has _anything_ to do with the coding
style of the code itself becides being in a readable format by
a developer?

And what does this have to do with android kernel specific things?

confused,

greg k-h

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. Your content must have a ListView whose id attribute is 'android.R.id.list'

I am currently receiving the error

java.lang.RuntimeException: Your content must have a ListView whose id
attribute is 'android.R.id.list'

and I cannot for the life of me figure out what i'm missing. Can
anybody assist me on this?

thanks

-- 

3. Why this Exception is coming ?

4. Setting multiple alarms

5. Fwd: Regarding thumb of the seek bar

6. Progressbar with Thumb image is not showing correctly on the 2.1 emulator

7. Switching GLSurface view and regular view issue.