rksahu1987 / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

About sometimes useing MyLocationOverlay can be blank screen #456

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.in my mapview's onCreate, I have 
 mLocationOverlay = new MyLocationOverlay(myMap.this,Mymapview); 
 Mymapview.getOverlays().add(mLocationOverlay);
2.but,sometimes,program can be process long time(black screen) within 
super(context, mapView) sentence at the construct of MyLocationOverlay class;

and long time,I can not see any output,if I fore stop vm, then the emulator can 
be popup a exception that "Activity ****(in application ***)is not responding."

My info:
PC OS: Win7-64
JDK:1.6
eclipse : adt-bundle-windows-x86_64
emulator : 2.2   4.0

my code following:

.....
    protected void onCreate(Bundle icicle) {
        // TODO Auto-generated method stub
        super.onCreate(icicle);
        setContentView(R.layout.navimap);
        mapv = (MapView)findViewById(R.id.navi_map);
        mapv.setTileSource(TileSourceFactory.MAPQUESTOSM);
        mapv.setBuiltInZoomControls(true);
        mapv.setUseDataConnection(true);
        mapv.setMultiTouchControls(true);
                mLocationOverlay = new MycaoLocationOverlay(navimap.this,mapv); //here is process long time             
            mapv.getOverlays().add(mLocationOverlay);

---------in the MycaoLocationOverlay class-----
    private Context context;
    private double offsetlat=0;
    private double offsetlng=0;
    Bitmap bmp;
    public MycaoLocationOverlay(Context context, MapView mapView) {
        super(context, mapView);//yes,this is do dispose long time,and don't come out       
        this.context = context;
        this.enableMyLocation();
        this.enableFollowLocation();
        this.enableCompass();
    }

Original issue reported on code.google.com by caoyan...@gmail.com on 29 Jul 2013 at 2:44

GoogleCodeExporter commented 8 years ago
Please try the MyLocationNewOverlay instead of the deprecated 
MyLocationOverlay. Also please look at the OpenStreetMapViewer project which 
shows how to properly use the location overlay. You should not be calling the 
enableXYZ() methods from the constructor of the overlay - you should be calling 
enableXYZ() from onResume() and disableXYZ() from onPause().

Original comment by kurtzm...@gmail.com on 7 Aug 2013 at 2:06

GoogleCodeExporter commented 8 years ago
thank you very much for your feedback.
  But  where is MyLocationNewOverlay class, My code is :
-------------------------------------
import org.osmdroid.views.overlay.MyLocationOverlay;

public class MycaoLocationOverlay extends MyLocationOverlay {
    private Context context;
    private double offsetlat=0;
    private double offsetlng=0;
    Bitmap bmp;
    public MycaoLocationOverlay(Context context, MapView mapView) {
        super(context, mapView);
        try {           
            this.context = context;
-----------------------------
So in org.osmdroid.views.overlay.* package has not MyLocationNewOverlay class, 
I found it.

Original comment by caoyan...@gmail.com on 8 Aug 2013 at 2:57

GoogleCodeExporter commented 8 years ago
The package/class name is 
org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay

Take a look at our sample project for an example on how to use:

https://code.google.com/p/osmdroid/source/browse/trunk/OpenStreetMapViewer/src/o
rg/osmdroid/MapFragment.java

Original comment by kurtzm...@gmail.com on 9 Aug 2013 at 2:41