0

I am building an application where i need a BitmapField on top of the MapField. This BitmapField need to be Draggable i.e. when I click on the BitmapField and move the cursor, BitmapField should move without moving the map. Is it possible?? How can i do this..?

Swati
  • 1,179
  • 9
  • 28

1 Answers1

0

Try this code:

public class Def extends MainScreen
{
VerticalFieldManager vertical;
BitmapField bitmapField;
int px=0,py=0;
public Def() 
{
    vertical=new VerticalFieldManager()
    {
        protected void sublayout(int maxWidth, int maxHeight) 
        {
            super.sublayout(Display.getWidth(),Display.getHeight());
            setExtent(Display.getWidth(),Display.getHeight());
        }       
    };
    vertical.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("background.png")));//put here map image;

    bitmapField=new BitmapField(Bitmap.getBitmapResource("rectanagle.png"));//For moving give small image;
    vertical.add(bitmapField);
    add(vertical);

}

protected boolean navigationMovement(int dx, int dy, int status, int time) 
{
    px=px+dx;
    py=py+dy;
    XYEdges xyEdges=new XYEdges(py, 0, 0, px);
    bitmapField.setPadding(xyEdges);
    vertical.invalidate();
    return super.navigationMovement(dx, dy, status, time);
}
}
alishaik786
  • 3,696
  • 2
  • 17
  • 25
  • I already gave a comment on code that where you put your map image; see the code once; Have any doubt come on following chat room: http://stackoverflow.com/questions/8937674/draggable-bitmapfield-in-blackberry/8939113#8939113 Here somany are there to give solutions – alishaik786 Jan 23 '12 at 06:06
  • I wanted to ask that.. how to get this map as an image..?? – Swati Jan 23 '12 at 06:29
  • Do you have any sample url to get the map from the server then I will provide you to how to get the map from server and convert it into Bitmap; Up to now I thought that you want a Movable image; That's why I don't put brain on that; – alishaik786 Jan 23 '12 at 06:50
  • I am not specific about adding the MapField or map image. I need to try out. i am adding a mapfield and at some specific coordinate I am adding a bitmap. Now I need to drag this bitmapfield on top of the mapfield(like you can drag in google maps A & B positions)..but not able to take any action on the Bitmap.. – Swati Jan 23 '12 at 09:42
  • Then how can you get the map image; and what is your requirement swati? – alishaik786 Jan 23 '12 at 09:42
  • come on this chat room: http://chat.stackoverflow.com/rooms/4014/knowledge-sharing-center-for-blackberry-and-java – alishaik786 Jan 23 '12 at 09:45