0

I've been trying to include the ability to show routes in an android app, and was working this solution into my app:

J2ME/Android/BlackBerry - driving directions, route between two locations

I've got basically all of the code in place, but in the drawPath method I get the error "The method toPixels(GeoPoint, Point) in the type Projection is not applicable for the arguments (GeoPoint, Point)" on the starred code below. Here's the code:

public void drawPath(MapView mMapView, Canvas canvas) 
    {
        int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
        Paint paint = new Paint();
        paint.setColor(Color.GREEN);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(3);
        for (int i = 0; i < mPoints.size(); i++) 
        {
            Point point = new Point();
            mMapView.getProjection().*****toPixels*****(mPoints.get(i), point);
            x2 = point.*****x*****;
            y2 = point.*****y*****;
            if (i > 0) 
            {
                canvas.drawLine(x1, y1, x2, y2, paint);
            }
            x1 = x2;
            y1 = y2;
        }
    }

I've not been able to test it at all yet because I've been unable to sort this error, so I don't know if there are other problems elsewhere. However in the meantime, if anybody knows why this error pops up it would be really appreciated. Thanks in advance! Oh and if anybody needs to see any of my other code or classes please let me know.

Community
  • 1
  • 1
  • In case it helps at all I've cut out the vast majority of the code here - if there's anything that needs putting back in please let me know! – Captain Chod Apr 27 '12 at 15:53
  • I couldnt solve the issue and went about it in a different way. The app is working fine now anyway. Thanks Agarwal – Captain Chod May 01 '12 at 11:37

2 Answers2

0

here is a good example i have posted you can try out this

MAC
  • 15,799
  • 8
  • 54
  • 95
  • Thanks gtumca-MAC. Unfortunately I've still new to Java and Android, and still can't see where I've gone wrong from your example.. One thing I have managed to is get rid of the error on the 'x' and 'y' by changing them to mLongitude and mLatitude, which were ints in my Point class. However I still can't see for the life of me why it's giving me that error on 'toPixels' as GeoPoint and Point seem to be the correct arguments I should be using... – Captain Chod Apr 26 '12 at 16:03
  • As a side note, I tried commenting out the line with the error on to see if the app runs ok up to that point, and it actually throws up a null pointer exception when it hits the for loop, so as yet the debugger doesn't even reach the toPixels line.. In the meantime I'm going to play around with the x and y int values in case they're having an effect – Captain Chod Apr 26 '12 at 19:31
0

I had tried this source code.

Copy the file from source code, don't change anything before that. DON'T press Ctrl + Shift + O to load library class automatically. Sometimes, eclipse import a wrong library. Why? That's another topic on eclipse.

Edit all these lines manually

import org.ci.geo.route.Road;
import org.ci.geo.route.RoadProvider;

Change import to your package library name.
Then edit this line that suit to your layout:

setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);

and this for sweet flavour

TextView textView = (TextView) findViewById(R.id.description);

Hope this will help you

chiwangc
  • 3,566
  • 16
  • 26
  • 32
Faizal
  • 783
  • 1
  • 6
  • 23