My map overlay is not showing up after several attempts
Here is my Overlay class code:
public class myOverlay extends Overlay{
private final int mRadius = 6;
@Override
public void draw(Canvas canvas, MapView mapView, boolean
shadow) {
super.draw(canvas, mapView, shadow);
Projection projection = mapView.getProjection();
// if (shadow == false) {
Double latitude = location.getLatitude()*1E6;
Double longitude = location.getLongitude()*1E6;
GeoPoint geoPoint;
geoPoint = new
GeoPoint(latitude.intValue(),longitude.intValue
());
Point point = new Point();
projection.toPixels(geoPoint, point);
RectF oval = new RectF(point.x - mRadius, point.y -
mRadius,
point.x + mRadius, point.y + mRadius);
// Setup the paint
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
Paint backPaint = new Paint();
backPaint.setARGB(175, 50, 50, 50);
backPaint.setAntiAlias(true);
RectF backRect = new RectF(point.x + 2 + mRadius,
point.y -
3*mRadius, point.x + 65, point.y + mRadius);
// Draw the marker
canvas.drawOval(oval, paint);
canvas.drawRoundRect(backRect, 5, 5, backPaint);
canvas.drawText(noteName, point.x + 2*mRadius, point.y,
paint);
// }
// else {
// }
}
@Override
public boolean onTap(GeoPoint point, MapView mapView) {
// Return true if screen tap is handled by this overlay
return false;
}
Location location;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
String noteName;
public String getNoteName(){
return noteName;
}
public void setNoteName(String n){
this.noteName = n;
}
}
Here is the call to add the overlay:
positionOverlay = new myOverlay();
Location loc = new Location("over");
loc.setLatitude(lat);
loc.setLongitude(lng);
positionOverlay.setLocation(loc);
positionOverlay.setNoteName(nm);
mapView.getOverlays().add(positionOverlay);
mapView.invalidate();
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en