Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm
Accepted Solution

Blakberry maps

Heloo every one this is my first post .

 

I m new to BB . I need the code for mapfield in which i can add my own markers and on clicking that markers new dialog showing info related that clicked marker apears ....Any one has any idea please do help me

 

Thanks in advanceSmiley Happy

Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm

Re: Blakberry maps

Still no answer any admin please help meSmiley Sad

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Blakberry maps

HAve you looked at the MapfieldDemo program source that ships with the dev tools?

 

Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm

Re: Blackberry maps


RexDoug wrote:

HAve you looked at the MapfieldDemo program source that ships with the dev tools?

 


Thank for your reply

 

yes sir I UnderStand the map demo code now I can invoke the map application with Landmarks but when I click the landmark on the map it throws an exception I want it to show the marker info in a dialog any idea ......?

 

thank in advance.......

Developer
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Blakberry maps

hi,

I have implemented it before all you need to extend mapfield class and create a custom map field class.

 

I am writing code in paint method of subclass of mapfield, try this and let me know if your problem is solved.

 

protected void paint(Graphics g) {
        super.paint(g);
        //if (null != mPointsBitmap) {
                //graphics.setGlobalAlpha(100);
                //graphics.drawBitmap(mDest, mPointsBitmap, 0, 0);
                int r=5;
                for(int i=0;i<mPoints.length-1;i++)
                {
                    XYPoint routeCoordinate = new XYPoint();
                    convertWorldToField(mPoints[i], routeCoordinate);
                    XYPoint routeNextCoordinate = new XYPoint();
                    convertWorldToField(mPoints[i+1], routeNextCoordinate);
                    g.setColor(Color.BLUE);
                    g.drawLine(routeCoordinate.x,routeCoordinate.y,routeNextCoordinate.x,routeNextCoordinate.y);
                    /*int lineXPoints[]={fieldOutPrevious.x,fieldOutPrevious.x,fieldOut.x,fieldOut.x,fieldOutPrevious.x};
                    int lineYPoints[]={fieldOutPrevious.y+r-3,fieldOutPrevious.y+r+3,fieldOut.y+r-3,fieldOut.y+r+3,fieldOutPrevious.y+r-3};
                    g.drawFilledPath(lineXPoints,lineYPoints,null,null);
                    g.setColor(Color.WHITE);*/
                }
                if (null != mPoint) {
                mPointDest = new XYRect[mPoints.length];
                for (int i = 0; i < mPoints.length; i++) {
                        if (null == mPointDest[i]) {
                                XYPoint fieldOut = new XYPoint();
                                convertWorldToField(mPoints[i], fieldOut);
                                
                                //int imgW = mPoint[i].getWidth();
                                //int imgH = mPoint[i].getHeight();
                                int imgW = r*4;
                                int imgH=  r*4;
                                
                                mPointDest[i] = new XYRect(fieldOut.x - imgW / 2,
                                                fieldOut.y - imgH, imgW, imgH);
                        
                                /*if(i!=0)
                                {
                                    XYPoint fieldOutPrevious = new XYPoint();
                                    convertWorldToField(mPoints[i-1], fieldOutPrevious);
                                    g.setColor(Color.DEEPSKYBLUE);
                                    
                                }*/
                                
                        }
                        InfoTraceRoute infoTraceRoute=(InfoTraceRoute)infoTraceMsg.elementAt(i);
                        //result.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
                        int annotationColor=0;
                        int annotationTextColor=0;
                        if(infoTraceRoute.strCurrentStatus.equals("STOP"))
                        {
                             annotationColor=Color.RED;
                             annotationTextColor=Color.WHITE;
                             
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("START"))
                        {
                                 annotationColor=Color.GREEN;
                                 annotationTextColor=Color.BLACK;
                                 
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("RUNNING"))
                        {
                                 annotationColor=Color.BLUE;
                                 annotationTextColor=Color.WHITE;
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("GEO OUT ALERT")||infoTraceRoute.strCurrentStatus.equals("GEO IN ALERT"))
                        {
                                 annotationColor=Color.ORANGE;
                                 annotationTextColor=Color.BLACK;
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("RUNNING OVER SPEED"))
                        {
                                 annotationColor=Color.BLACK;
                                 annotationTextColor=Color.WHITE;
                        }
                        else
                        {
                                 annotationColor=Color.YELLOW;
                                 annotationTextColor=Color.BLACK;
                        }
                        g.setColor(annotationColor);
                        int xPoints[]={mPointDest[i].x,mPointDest[i].x,mPointDest[i].x+2*r-5,mPointDest[i].x+2*r,mPointDest[i].x+2*r+5,mPointDest[i].x+4*r,mPointDest[i].x+4*r};
                        int yPoints[]={mPointDest[i].y,mPointDest[i].y+4*r,mPointDest[i].y+4*r,mPointDest[i].y+5*r,mPointDest[i].y+4*r,mPointDest[i].y+4*r,mPointDest[i].y};
                        g.drawFilledPath(xPoints, yPoints,null,null);
                        g.setColor(annotationTextColor);
                        g.setFont(g.getFont().derive(Font.BOLD ,10));
                        g.drawText(""+infoTraceRoute.intCount,mPointDest[i].x+r,mPointDest[i].y+r);
                        
                }
                if(selectedPoint>=0)
                {
                    //g.setGlobalAlpha(0xff);
                    System.out.println(selectedPoint);
                    g.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS, true);
                    InfoTraceRoute infoTraceRoute=(InfoTraceRoute)this.infoTraceMsg.elementAt(selectedPoint);
                    
                    String annotationTitle=infoTraceRoute.intCount+" "+infoTraceRoute.strCurrentStatus+" "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLatitude))+
                                            " "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLongitude));
                    String annotationSubTitle=infoTraceRoute.strReceivedDate+" "+infoTraceRoute.strRunningSpeed;
                    int length=annotationTitle.length()>annotationSubTitle.length()? annotationTitle.length():annotationSubTitle.length();
                    g.setColor(0x757575);
                    g.fillRect(mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].y-60,length*6+6,28);
                    g.setColor(0x525250);
                
                
                    int xPoints[]={mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-3,
                                    mPointDest[selectedPoint].x+5,mPointDest[selectedPoint].x+5, mPointDest[selectedPoint].x+length*6,
                                    mPointDest[selectedPoint].x+length*6};
                    int yPoints[]={mPointDest[selectedPoint].y-32,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y-32};
                    //g.setColor(Color.BLUE);
                    g.drawFilledPath(xPoints,yPoints,null,null);
                    g.setColor(Color.BLACK);
                    g.setFont(g.getFont().derive(Font.BOLD ,10));
                    g.drawText(annotationTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-55);
                    g.drawText(annotationSubTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-30);
                    
                    
                
                }
            }
                
        //}
    }
    
    
    protected boolean touchEvent(TouchEvent event)
    {
        super.touchEvent(event);
        endX=event.getX(1);
        endY=event.getY(1);
        switch( event.getEvent()  )
        {
            
            case TouchEvent.DOWN:  
                        System.out.println("inside touchevent down");
                        startX=endX;
                        startY=endY;
                        return true;
            case TouchEvent.MOVE:
                            System.out.println("inside touchevent move");
                            start = new XYPoint(startX,startY);
                            end = new XYPoint(endX,endY);
                            start_world = new XYPoint(s_lat,s_lon);
                            end_world = new XYPoint(e_lat,e_lon);
                            convertFieldToWorld(start,start_world);
                            convertFieldToWorld(end,end_world);            
                            //System.out.println("DownLan ("+start_world.x+" , "+start_world.y+") and UpLon ("+end_world.x+" , "+end_world.y+").");                        
                            int newlan = start_world.y-end_world.y;            
                            newlan=newlan/((getZoom()/2)+1);
                            int newlon = start_world.x-end_world.x;  
                            newlon=newlon/((getZoom()/2)+1);          
                            int lat=newlan+getLatitude();                       
                            int lon=newlon+getLongitude();            
            
                            if(lat < -9000000)
                            {
                                lat= -9000000;
                            }
                            if(lat > 9000000)
                            {
                                lat= 9000000;
                            }
                   
                            if(lon < -18000000)
                            {
                                lon= -18000000;
                            }
                            if(lon > 18000000)
                            {
                                lon= 18000000;
                            }              
            
                            moveTo( lat , lon );
                            invalidate();         
                            return true;
            case TouchEvent.UP:
                            System.out.println("inside touchevent up");
                            startX=-1;
                            startY=-1;
                            return true;   

            case TouchEvent.CLICK:
                            System.out.println("inside touch click");
                            int i=mPointDest.length-1;
                            for(;i>=0;i--)
                            {
                                if(event.getX(1)>=mPointDest[i].x && event.getX(1)<=mPointDest[i].x+mPoint[i].getWidth() &&
                                    event.getY(1)>=mPointDest[i].y && event.getY(1)<=mPointDest[i].y+mPoint[i].getHeight())
                                    {
                                        System.out.println("point clicked"+i);
                                        selectedPoint=i;
                                        invalidate();
                                        //repaintPoints();
                                        break;
                                    }
                            }
                            if(i<0)
                            {
                                if(selectedPoint<0)
                                {
                                    if(getZoom()>getMinZoom())
                                        setZoom(getZoom()-1);
                                }
                                else       
                                    selectedPoint=-1;
                                invalidate();
                                repaintPoints();
                            }
                            
                            return true;
        }
        return false;
        
    }
    
    public void repaintMap()
    {
        invalidate();
    }                       

Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm

Re: Blackberry maps

Thank you Mr.. jitendrasharma  for replying me. Give me a favor I m new to black berry can you please post your whole Custom map class so that I can understand it easily and if any one has any idea how to show the map and a search panel in a same screen. If I press the search button on that screen the map changes according to the Search result and search panel remains unchanged.

Developer
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Blakberry maps

hi hassan_butter,

below is full source code of CustomMapField just copy paste it in your class, in which screen you are adding this map field call

 

MultiMapField mMultiMapField=new MultiMapField(ArrayList arrayOfCoordinates);

append(mMultiMapField);

I am sending a array list of objects which i think not of your interest it contain strings which are to be displayed and coordinates of points,

 

now add this mMultiMapField to your manager.

 

I didnt implemented search panel but i think you can get help regarding this in map field demo.

 

below is full source code of CustomMapField:

 

 

public class MultiMapField extends MapField {
    //Coordinates[] mPoints = new Coordinates[0];
    public Coordinates[] mPoints=null;
    public Bitmap[] mPoint;
    Bitmap mPointsBitmap;
    XYRect mDest;
    public XYRect[] mPointDest;
    public int selectedPoint=-1;
    Vector infoTraceMsg=null;
    public int startX=-1;
    public int startY=-1;
    public int endX;
    public int endY;
    public int s_lat;
    public int s_lon;
    public int e_lat;
    public int e_lon;
    public XYPoint start;
    public XYPoint end;
    public XYPoint start_world;
    public XYPoint end_world;
    public MultiMapField(Vector infoTraceMsg)
    {
        this.infoTraceMsg=infoTraceMsg;
        mPoints=new Coordinates[infoTraceMsg.size()];
        for(int i=0;i<infoTraceMsg.size();i++)
        {
            InfoTraceRoute infoTraceRoute=(InfoTraceRoute)infoTraceMsg.elementAt(i);
            mPoints[i]=new Coordinates(infoTraceRoute.doubleLatitude, infoTraceRoute.doubleLongitude,Float.NaN);
            
        }
        zoomToFitPoints();
        //repaintPoints();
        //this.setZoom(8);
        setZoom((getMaxZoom()+getMinZoom())/2);
    }
    public void addCoordinates(Coordinates coordinates) {
        Arrays.add(mPoints, coordinates);
        zoomToFitPoints();
        repaintPoints();
    }

    public void addCoordinates(Coordinates coordinates[]) {
        //Arrays.add(mPoints, coordinates);
        mPoints=coordinates;
        zoomToFitPoints();
        repaintPoints();
    }
    protected void zoomToFitPoints() {
        // zoom to max
        setZoom(getMaxZoom());
        /*
        if(mPoints.length==1)
        {
            Coordinates center = new Coordinates(mPoints[0].getLatitude(), mPoints[0].getLongitude(), 0);
            this.moveTo(center);
        }*/
        int midPoint=0;
        if(mPoints.length%2==0)
            midPoint=mPoints.length/2;
        else
            midPoint=(mPoints.length+1)/2;
        
        this.moveTo(mPoints[midPoint]);
        // get pixels of all points
        int minLeft = getWidth();
        int minUp = getHeight();
        int maxRight = 0;
        int maxDown = 0;
        Coordinates minLeftCoordinates = null;
        Coordinates minUpCoordinates = null;
        Coordinates maxRightCoordinates = null;
        Coordinates maxDownCoordinates = null;
        for (int i = 0; i < mPoints.length; i++) {
                XYPoint point = new XYPoint();
                convertWorldToField(mPoints[i], point);
                if (point.x <= minLeft) {
                    
                        minLeft = point.x;
                        minLeftCoordinates = mPoints[i];
                }
                if (point.x >= maxRight) {
                        maxRight = point.x;
                        maxRightCoordinates = mPoints[i];
                }
                if (point.y <= minUp) {
                        minUp = point.y;
                        minUpCoordinates = mPoints[i];
                }
                if (point.y >= maxDown) {
                        maxDown = point.y;
                        maxDownCoordinates = mPoints[i];
                }
                /*while(minLeft<0)
                {
                    moveTo()
                }*/
        }
        
        /*if(maxRightCoordinates==null)
        {
            XYPoint point = new XYPoint();
            convertWorldToField(mPoints[0], point);
            maxRight = point.x;
            maxRightCoordinates = mPoints[0];
        }
        if(maxDownCoordinates==null)
        {
            XYPoint point = new XYPoint();
            convertWorldToField(mPoints[0], point);
            maxDown = point.y;
            maxDownCoordinates = mPoints[0];
        } */    
        double moveToLat = maxDownCoordinates.getLatitude()
                        + (minUpCoordinates.getLatitude() - maxDownCoordinates
                                        .getLatitude()) / 2;
        double moveToLong = minLeftCoordinates.getLongitude()
                        + (maxRightCoordinates.getLongitude() - minLeftCoordinates
                                        .getLongitude()) / 2;
        Coordinates moveTo = new Coordinates(moveToLat, moveToLong, 0);
        moveTo(moveTo);
        // zoom to min left up, max right down pixels + 1
        int zoom = getZoom();
        boolean outOfBounds = false;
        while (!outOfBounds && zoom > getMinZoom()) {
                zoom--;
                setZoom(zoom);
                XYPoint point = new XYPoint();
                try {
                        convertWorldToField(minLeftCoordinates, point);
                        if (point.x < 0)
                                outOfBounds = true;
                        convertWorldToField(minUpCoordinates, point);
                        if (point.y < 0)
                                outOfBounds = true;
                        convertWorldToField(maxRightCoordinates, point);
                        if (point.x > getWidth())
                                outOfBounds = true;
                        convertWorldToField(maxDownCoordinates, point);
                        if (point.y > getHeight())
                                outOfBounds = true;
                } catch (IllegalArgumentException ex) {
                        outOfBounds = true;
                }
        }
        zoom++;
        setZoom(zoom);
    }

    protected void repaintPoints() {
        mPointsBitmap = new Bitmap(getWidth(), getHeight());
        mPointsBitmap.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
        mDest = new XYRect(0, 0, mPointsBitmap.getWidth(), mPointsBitmap.getHeight());
        Graphics g = new Graphics(mPointsBitmap);
        if (null != mPoint) {
                mPointDest = new XYRect[mPoints.length];
                for (int i = 0; i < mPoints.length; i++) {
                        if (null == mPointDest[i]) {
                                XYPoint fieldOut = new XYPoint();
                                convertWorldToField(mPoints[i], fieldOut);
                                
                                int imgW = mPoint[i].getWidth();
                                int imgH = mPoint[i].getHeight();
                                mPointDest[i] = new XYRect(fieldOut.x - imgW / 2,
                                                fieldOut.y - imgH, imgW, imgH);
                                if(i!=0)
                                {
                                    XYPoint fieldOutPrevious = new XYPoint();
                                    convertWorldToField(mPoints[i-1], fieldOutPrevious);
                                    //g.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS,true);
                                    //g.tileRop(
                                    g.setColor(Color.DEEPSKYBLUE);
                                    //g.setStrokeWidth(20);
                                    //
                                    g.drawLine(fieldOutPrevious.x, fieldOutPrevious.y,fieldOut.x,fieldOut.y);    
                                }
                                
                        }
                        g.drawBitmap(mPointDest[i], mPoint[i], 0, 0);
                        
                }
                if(selectedPoint>=0)
                {
                    //g.setGlobalAlpha(0xff);
                    System.out.println(selectedPoint);
                    g.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS, true);
                    InfoTraceRoute infoTraceRoute=(InfoTraceRoute)this.infoTraceMsg.elementAt(selectedPoint);
                    
                    String annotationTitle=infoTraceRoute.intCount+" "+infoTraceRoute.strCurrentStatus+" "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLatitude))+
                                            " "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLongitude));
                    String annotationSubTitle=infoTraceRoute.strReceivedDate+" "+infoTraceRoute.strRunningSpeed;
                    int length=annotationTitle.length()>annotationSubTitle.length()? annotationTitle.length():annotationSubTitle.length();
                    g.setColor(0x757575);
                    g.fillRect(mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].y-60,length*6+6,28);
                    g.setColor(0x525250);
                
                
                    int xPoints[]={mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-3,
                                    mPointDest[selectedPoint].x+5,mPointDest[selectedPoint].x+5, mPointDest[selectedPoint].x+length*6,
                                    mPointDest[selectedPoint].x+length*6};
                    int yPoints[]={mPointDest[selectedPoint].y-32,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y-32};
                    //g.setColor(Color.BLUE);
                    g.drawFilledPath(xPoints,yPoints,null,null);
                    g.setColor(Color.BLACK);
                    g.setFont(g.getFont().derive(Font.BOLD ,10));
                    g.drawText(annotationTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-55);
                    g.drawText(annotationSubTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-30);
                    
                    
                
                }
        }
    }

    protected void paint(Graphics g) {
        super.paint(g);
        //if (null != mPointsBitmap) {
                //graphics.setGlobalAlpha(100);
                //graphics.drawBitmap(mDest, mPointsBitmap, 0, 0);
                int r=5;
                for(int i=0;i<mPoints.length-1;i++)
                {
                    XYPoint routeCoordinate = new XYPoint();
                    convertWorldToField(mPoints[i], routeCoordinate);
                    XYPoint routeNextCoordinate = new XYPoint();
                    convertWorldToField(mPoints[i+1], routeNextCoordinate);
                    g.setColor(Color.BLUE);
                    g.drawLine(routeCoordinate.x,routeCoordinate.y,routeNextCoordinate.x,routeNextCoordinate.y);
                    /*int lineXPoints[]={fieldOutPrevious.x,fieldOutPrevious.x,fieldOut.x,fieldOut.x,fieldOutPrevious.x};
                    int lineYPoints[]={fieldOutPrevious.y+r-3,fieldOutPrevious.y+r+3,fieldOut.y+r-3,fieldOut.y+r+3,fieldOutPrevious.y+r-3};
                    g.drawFilledPath(lineXPoints,lineYPoints,null,null);
                    g.setColor(Color.WHITE);*/
                }
                if (null != mPoint) {
                mPointDest = new XYRect[mPoints.length];
                for (int i = 0; i < mPoints.length; i++) {
                        if (null == mPointDest[i]) {
                                XYPoint fieldOut = new XYPoint();
                                convertWorldToField(mPoints[i], fieldOut);
                                
                                //int imgW = mPoint[i].getWidth();
                                //int imgH = mPoint[i].getHeight();
                                int imgW = r*4;
                                int imgH=  r*4;
                                
                                mPointDest[i] = new XYRect(fieldOut.x - imgW / 2,
                                                fieldOut.y - imgH, imgW, imgH);
                        
                                /*if(i!=0)
                                {
                                    XYPoint fieldOutPrevious = new XYPoint();
                                    convertWorldToField(mPoints[i-1], fieldOutPrevious);
                                    g.setColor(Color.DEEPSKYBLUE);
                                    
                                }*/
                                
                        }
                        InfoTraceRoute infoTraceRoute=(InfoTraceRoute)infoTraceMsg.elementAt(i);
                        //result.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
                        int annotationColor=0;
                        int annotationTextColor=0;
                        if(infoTraceRoute.strCurrentStatus.equals("STOP"))
                        {
                             annotationColor=Color.RED;
                             annotationTextColor=Color.WHITE;
                             
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("START"))
                        {
                                 annotationColor=Color.GREEN;
                                 annotationTextColor=Color.BLACK;
                                 
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("RUNNING"))
                        {
                                 annotationColor=Color.BLUE;
                                 annotationTextColor=Color.WHITE;
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("GEO OUT ALERT")||infoTraceRoute.strCurrentStatus.equals("GEO IN ALERT"))
                        {
                                 annotationColor=Color.ORANGE;
                                 annotationTextColor=Color.BLACK;
                        }
                        else if(infoTraceRoute.strCurrentStatus.equals("RUNNING OVER SPEED"))
                        {
                                 annotationColor=Color.BLACK;
                                 annotationTextColor=Color.WHITE;
                        }
                        else
                        {
                                 annotationColor=Color.YELLOW;
                                 annotationTextColor=Color.BLACK;
                        }
                        g.setColor(annotationColor);
                        int xPoints[]={mPointDest[i].x,mPointDest[i].x,mPointDest[i].x+2*r-5,mPointDest[i].x+2*r,mPointDest[i].x+2*r+5,mPointDest[i].x+4*r,mPointDest[i].x+4*r};
                        int yPoints[]={mPointDest[i].y,mPointDest[i].y+4*r,mPointDest[i].y+4*r,mPointDest[i].y+5*r,mPointDest[i].y+4*r,mPointDest[i].y+4*r,mPointDest[i].y};
                        g.drawFilledPath(xPoints, yPoints,null,null);
                        g.setColor(annotationTextColor);
                        g.setFont(g.getFont().derive(Font.BOLD ,10));
                        g.drawText(""+infoTraceRoute.intCount,mPointDest[i].x+r,mPointDest[i].y+r);
                        
                }
                if(selectedPoint>=0)
                {
                    //g.setGlobalAlpha(0xff);
                    System.out.println(selectedPoint);
                    g.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLYGONS, true);
                    InfoTraceRoute infoTraceRoute=(InfoTraceRoute)this.infoTraceMsg.elementAt(selectedPoint);
                    
                    String annotationTitle=infoTraceRoute.intCount+" "+infoTraceRoute.strCurrentStatus+" "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLatitude))+
                                            " "+MathUtilities.round(MathUtilities.round(infoTraceRoute.doubleLongitude));
                    String annotationSubTitle=infoTraceRoute.strReceivedDate+" "+infoTraceRoute.strRunningSpeed;
                    int length=annotationTitle.length()>annotationSubTitle.length()? annotationTitle.length():annotationSubTitle.length();
                    g.setColor(0x757575);
                    g.fillRect(mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].y-60,length*6+6,28);
                    g.setColor(0x525250);
                
                
                    int xPoints[]={mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-5,mPointDest[selectedPoint].x-3,
                                    mPointDest[selectedPoint].x+5,mPointDest[selectedPoint].x+5, mPointDest[selectedPoint].x+length*6,
                                    mPointDest[selectedPoint].x+length*6};
                    int yPoints[]={mPointDest[selectedPoint].y-32,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y,mPointDest[selectedPoint].y-5,mPointDest[selectedPoint].y-5,
                                    mPointDest[selectedPoint].y-32};
                    //g.setColor(Color.BLUE);
                    g.drawFilledPath(xPoints,yPoints,null,null);
                    g.setColor(Color.BLACK);
                    g.setFont(g.getFont().derive(Font.BOLD ,10));
                    g.drawText(annotationTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-55);
                    g.drawText(annotationSubTitle, mPointDest[selectedPoint].x-3, mPointDest[selectedPoint].y-30);
                    
                    
                
                }
            }
                
        //}
    }
    
    
    protected boolean touchEvent(TouchEvent event)
    {
        super.touchEvent(event);
        endX=event.getX(1);
        endY=event.getY(1);
        switch( event.getEvent()  )
        {
            
            case TouchEvent.DOWN:  
                        System.out.println("inside touchevent down");
                        startX=endX;
                        startY=endY;
                        return true;
            case TouchEvent.MOVE:
                            System.out.println("inside touchevent move");
                            start = new XYPoint(startX,startY);
                            end = new XYPoint(endX,endY);
                            start_world = new XYPoint(s_lat,s_lon);
                            end_world = new XYPoint(e_lat,e_lon);
                            convertFieldToWorld(start,start_world);
                            convertFieldToWorld(end,end_world);            
                            //System.out.println("DownLan ("+start_world.x+" , "+start_world.y+") and UpLon ("+end_world.x+" , "+end_world.y+").");                        
                            int newlan = start_world.y-end_world.y;            
                            newlan=newlan/((getZoom()/2)+1);
                            int newlon = start_world.x-end_world.x;  
                            newlon=newlon/((getZoom()/2)+1);          
                            int lat=newlan+getLatitude();                       
                            int lon=newlon+getLongitude();            
            
                            if(lat < -9000000)
                            {
                                lat= -9000000;
                            }
                            if(lat > 9000000)
                            {
                                lat= 9000000;
                            }
                   
                            if(lon < -18000000)
                            {
                                lon= -18000000;
                            }
                            if(lon > 18000000)
                            {
                                lon= 18000000;
                            }              
            
                            moveTo( lat , lon );
                            invalidate();         
                            return true;
            case TouchEvent.UP:
                            System.out.println("inside touchevent up");
                            startX=-1;
                            startY=-1;
                            return true;   

            case TouchEvent.CLICK:
                            System.out.println("inside touch click");
                            int i=mPointDest.length-1;
                            for(;i>=0;i--)
                            {
                                if(event.getX(1)>=mPointDest[i].x && event.getX(1)<=mPointDest[i].x+mPoint[i].getWidth() &&
                                    event.getY(1)>=mPointDest[i].y && event.getY(1)<=mPointDest[i].y+mPoint[i].getHeight())
                                    {
                                        System.out.println("point clicked"+i);
                                        selectedPoint=i;
                                        invalidate();
                                        //repaintPoints();
                                        break;
                                    }
                            }
                            if(i<0)
                            {
                                if(selectedPoint<0)
                                {
                                    if(getZoom()>getMinZoom())
                                        setZoom(getZoom()-1);
                                }
                                else       
                                    selectedPoint=-1;
                                invalidate();
                                repaintPoints();
                            }
                            
                            return true;
        }
        return false;
        
    }
    
    public void repaintMap()
    {
        invalidate();
    }                        
 }

Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm

Re: Blackberry maps

Thank you very much Mr..jitendrasharma  . The problem is almost resolved .

 

But I need to know that weather there is any difference between designing UI using widget and simple Blackberry application..

 

If there is any difference then what is that.. And Mr..jitendrasharma   can you please mail me at hassanbuttars@gmail.com I need to send you snapshots that I have to implement using Simple UI or using widgets....?

 

 

Thanks in advance Smiley Happy

Developer
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: Blackberry maps

And as far I know blackberry widgets are some application written in html, css, and java script for blackberry, which would run on browser.

 

I think code security is main difference between applications and widgets, because from widgets any one can find source code of application easily, without any prob, however in blackberry application we deploy jar or cod file, which is difficult to decrypt.

 

 

Contributor
Posts: 31
Registered: ‎06-29-2010
My Device: 9550
My Carrier: telenor gsm

Re: Blackberry maps

Yes you are right Mr..jitendrasharma  but I wants to know that can every functionality of blackberry is implemented using widgets or there are some limitations .....Can we import our class objects in widget if yes then how ..I wants to use Ksoap at login screen can I do this if that screen is implemented using widget......?