Hi all,

I'm running 0.9 in Eclipse 3.3/ADT.
I have a very stripped down one-class app (converted from m5) which
ought to be
presenting a map (that works ok) and then drawing an overlay (it
doesn't).
In onCreate(), a simple overlay (TOverlay) is created and added to
_mapView.getOverlays().
Lastly, mapUpdateHandler.sendEmptyMessage() is called, which should
invalidate the mapView,
and hence cause the overlay to be drawn.


I've copied the code below, and then copied the manifest.
The code has a few System.out.println's to determine flow of control.
All these appear in the LogCat output except the one in the overlay:
"TOverlay.draw".
At the very end I've copied the LogCat output.  One can see the
printlns:


09-09 15:18:06.332: INFO/System.out(695): o2:1
09-09 15:18:06.352: INFO/System.out(695): mUH:msg=101
09-09 15:18:06.352: INFO/System.out(695): mUH:101
09-09 15:18:06.352: INFO/System.out(695): o3: 1


But not the desired "TOverlay.draw"


Any suggestions will be greatly appreciated.
Thanks in advance,
Ken


-------------- Java ----------
package com.herenow.android.quester;


import java.util.List;


public class Quester extends MapActivity
{
        private static final double INIT_CENTER_LAT = 42.3908245;
        private static final double INIT_CENTER_LONG = -71.130993;
        private MapView _mapView;


    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        _mapView = new MapView(this, "dummyapikey");
        GeoPoint p = new GeoPoint((int) (INIT_CENTER_LAT * 1000000),
(int) (INIT_CENTER_LONG * 1000000));
        MapController mc = _mapView.getController();


        TOverlay tOver = new TOverlay(_mapView);
        List<Overlay> overlays = _mapView.getOverlays();
        overlays.add(tOver);


        mc.animateTo(p);
        mc.setZoom(15);
        setContentView(_mapView);


        mapUpdateHandler.sendEmptyMessage(101);
List<Overlay> o2 = _mapView.getOverlays();
System.out.println("o2:"+o2.size());
    }
    private Handler mapUpdateHandler
        = new Handler(){
                @Override
                public void handleMessage(Message msg) {
                        System.out.println("mUH:msg="+msg.what);
                    switch (msg.what) {
                          case 101:
                   //         _mapView.invalidate();
                            _mapView.postInvalidate();
                            System.out.println("mUH:101");
                                       break;
                             }
List <Overlay> o3 = _mapView.getOverlays();
System.out.println("o3: "+o3.size());
                     super.handleMessage(msg);
                }
            };


    public class TOverlay extends Overlay
    {
        private Paint plotPaint = new Paint();
        private MapView mapView;


        public TOverlay(MapView mapView){
                this.mapView = mapView;
                plotPaint.setColor(Color.BLUE);
        }


        public synchronized void draw(Canvas canvas, boolean b)
        {
            super.draw(canvas, mapView, b);
System.out.println("TOverlay.draw");


            int lat = (int)(INIT_CENTER_LAT*1E6);
                int lng = (int)(INIT_CENTER_LONG*1E6);
            GeoPoint geopoint = new GeoPoint(lat, lng);


            Point screenCoords = new Point();
            mapView.getProjection().toPixels(geopoint, screenCoords);
            canvas.drawCircle(screenCoords.x, screenCoords.y, 12,
plotPaint);
        }
    }


    public boolean isRouteDisplayed(){
        return false;
    }


}


--------------- Manifest -------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
    package="com.herenow.android.quester">
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon">
        <activity android:name=".Quester" android:label="@string/
app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="com.google.android.maps" />
    </application>
</manifest>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
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