




androidUser wrote:Envrionment: SDK1.0
Question:
1) I need to display balloon similarly as you shown in your image text_overlay_878.jpg.
2) Is it possible to add link in the balloon. So that if i click the link in balloon i can goto newIntent screen taking the input of current clicked message.
Please find the below code and the attached output.png, also you can find the attached complete java file.
private void drawInfoWindow(Canvas canvas, MapView mapView, boolean shadow) {
if ( selectedMapLocation != null) {
if ( shadow) {
// Skip painting a shadow in this tutorial
} else {
// First determine the screen coordinates of the selected MapLocation
Point selDestinationOffset = new Point();
mapView.getProjection().toPixels(selectedMapLocation.getPoint(), selDestinationOffset);
// Setup the info window with the right size & location
int INFO_WINDOW_WIDTH = 250;
int INFO_WINDOW_HEIGHT = 50;
RectF infoWindowRect = new RectF(0,0,INFO_WINDOW_WIDTH,INFO_WINDOW_HEIGHT);
int infoWindowOffsetX = selDestinationOffset.x-INFO_WINDOW_WIDTH/2;
int infoWindowOffsetY = selDestinationOffset.y-INFO_WINDOW_HEIGHT-bubbleIcon.getHeight();
infoWindowRect.offset(infoWindowOffsetX,infoWindowOffsetY);
// Draw inner info window
canvas.drawRoundRect(infoWindowRect, 5, 5, getInnerPaint());
// Draw border for info window
canvas.drawRoundRect(infoWindowRect, 5, 5, getBorderPaint());
// Draw the MapLocation's name
int TEXT_OFFSET_X = 10;
int TEXT_OFFSET_Y = 15;
canvas.drawText(selectedMapLocation.getName(),infoWindowOffsetX+TEXT_OFFSET_X,infoWindowOffsetY+TEXT_OFFSET_Y,getTextPaint());
}
}
}

burakkilic wrote:
Could you solve the problem? I added a TableLayout object in the onTap event of the overlay. But it's not beautiful as the shadowed overlay. I am looking for a better way.

burakkilic wrote:I used Inflater finally. But that overlay is not shadowed.


burakkilic wrote:Using java Syntax Highlighting
if(table==null){ table = (LinearLayout)inflater.inflate(R.layout.infooverlay, null); table.setWillNotDraw(false); } Parsed in 0.030 seconds, using GeSHi 1.0.8.4
table is an instance of a LinearLayout. and the R.layout.infooverlay is an xml layout file in the resources.
inflater is a LayoutInflater inflater;
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if (shadow == false) {
Projection projection = mapView.getProjection();
if(myGeoPoint!=null){
Point myPoint = new Point();
projection.toPixels(myGeoPoint, myPoint);
drawGeoPoint(canvas, myPoint);
}
} else {
}
}
private void drawGeoPoint(Canvas canvas, Point point){
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
if(highlighted)
paint.setARGB(250, 0, 255, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
// Create the circle
int rad = 10;
RectF oval = new RectF(point.x-rad, point.y-rad,
point.x+rad, point.y+rad);
// Draw on the canvas
canvas.drawOval(oval, paint);
canvas.drawText(myTitle, point.x+rad, point.y, paint);
this.hitTestArea = oval;
}


burakkilic wrote:To draw a view on the map: mapview.addView() method
To add overlays: mapview.getOverlays().add() method.
I advise u to search for these methods.


Users browsing this forum: No registered users and 1 guest