The canvas needs something to draw onto.  However, in your case you
might be better served adding your code to the draw method in
HelloItemizedOverlay.
That method has a canvas passed to it which will already by correctly
set up.

On Jun 21, 2:05 am, mnish <[email protected]> wrote:
> Hello,
> I have a problem with drawing lines between two points on google map.
> I get nullpointerexception on this line of code:
> canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint);
>
> I know this is a very basic thing, but I don't know not much about it
> and I really really need your help.
>
> here is were i call this method:
>
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>                 super.onCreate(savedInstanceState);
>                 setContentView(R.layout.main);
>
>                 linearLayout = (LinearLayout) findViewById
> (R.id.zoomview);
>                 mapView = (MapView) findViewById(R.id.mapview);
>                 mapView.setBuiltInZoomControls(on);
>                 mapOverlays = mapView.getOverlays();
>                 drawable = this.getResources().getDrawable
> (R.drawable.circle);
>                 itemizedoverlay = new HelloItemizedOverlay(drawable);
>                 Projection projection = mapView.getProjection();
>
>                 Double lat1 = 30.342833*1E6, lon1 = -91.719033*1E6;
>                 Double lat2 = -37.5262180*1E6, lon2 = 175.8060710*1E6;
>                 point1 = new GeoPoint(lat1.intValue(), lon1.intValue
> ());
>                 point2 = new GeoPoint(lat2.intValue(), lon2.intValue
> ());
>                 p1 = new Point();
>                 p2 = new Point();
>                 projection.toPixels(point1, p1);
>                 projection.toPixels(point2, p2);
>                 canvas = new Canvas();
>                 canvas.drawLine(p1.x, p1.y, p2.x, p2.y, paint);
>
>         }.
>
> Please tell me what do i do wrong.
> Any help is more than welcome
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to