Canvas.drawPath undefined?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Canvas.drawPath undefined?

Postby retraffic » Tue May 17, 2011 8:40 am

Hello,
i'm new to android programming but i've already been able to draw markers to my mapview. But now I have to draw a Line on it. I have tried using a lot of tutorials, which all led to a syntax error. Somehow the program can't find the methods in Canvas.

"The method drawPath(Path, Paint) is undefined for the type Canvas"

The same thing is happening while using most other methods like drawLine etc. Can anyone guess what the problem could be?

Thank you.

The class file:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.Seuche;
  2.  
  3. import android.graphics.Canvas;
  4. import android.graphics.Color;
  5. import android.graphics.Paint;
  6. import android.graphics.Path;
  7. import android.graphics.Point;
  8.  
  9. import com.google.android.maps.GeoPoint;
  10. import com.google.android.maps.MapView;
  11. import com.google.android.maps.Overlay;
  12. import com.google.android.maps.Projection;
  13.  
  14. public class GebietOverlay extends Overlay {
  15.     private GeoPoint geoPoint1;
  16.     private GeoPoint geoPoint2;
  17.     private Point point1;
  18.     private Point point2;
  19.     private Projection projection;
  20.  
  21.     public GebietOverlay(MapView mapView){
  22.         projection = mapView.getProjection();
  23.     }
  24.  
  25.     public void draw(Canvas canvas, MapView mapView, boolean shadow){
  26.         super.draw(canvas, mapView, shadow);
  27.         Paint paint = new Paint();
  28.         paint.setDither(true);
  29.         paint.setColor(Color.BLUE);
  30.         paint.setStyle(Paint.Style.FILL_AND_STROKE);
  31.         paint.setStrokeJoin(Paint.Join.ROUND);
  32.         paint.setStrokeCap(Paint.Cap.ROUND);
  33.         paint.setStrokeWidth(2);
  34.        
  35.         point1 = new Point();
  36.         point2 = new Point();
  37.         Path path = new Path();
  38.        
  39.        
  40.        
  41.         geoPoint1 = new GeoPoint(00000,9233232);
  42.         geoPoint2 = new GeoPoint(102232320,9992234);
  43.        
  44.         projection.toPixels(geoPoint1, point1);
  45.         projection.toPixels(geoPoint2, point2);
  46.        
  47.         path.moveTo(point2.x, point2.y);
  48.         path.moveTo(point1.x, point1.y);
  49.        
  50.         canvas.drawPath(path, paint);
  51.     }
  52. }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
retraffic
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 17, 2011 8:28 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests