android - OsmDroid show current LocationIcon not working -
i'm using osmdroid in android app. works fine except can not display icon show current location. following code:
openmapview = (org.osmdroid.views.mapview) v.findviewbyid(r.id.openmapview); openmapview.setclickable(true); openmapview.setmultitouchcontrols(true); final float scale = getresources().getdisplaymetrics().density; final int newscale = (int) (256 * scale); string[] osmsource = new string[2]; osmsource[0] = "http://a.tile.openstreetmap.org/"; osmsource[1] = "http://b.tile.openstreetmap.org/"; xytilesource mapsource = new xytilesource( "osm", null, 1, 18, newscale, ".png", osmsource ); openmapview.settilesource(mapsource); mapcontroller = (mapcontroller) openmapview.getcontroller(); mapcontroller.setzoom(14); // location overlay mylocationoverlay = new mylocationoverlay(getactivity(), openmapview); mylocationoverlay.enablemylocation(); // not on default mylocationoverlay.enablecompass(); mylocationoverlay.disablefollowlocation(); mylocationoverlay.setdrawaccuracyenabled(true); mylocationoverlay.runonfirstfix(new runnable() { public void run() { mapcontroller.animateto(mylocationoverlay.getmylocation()); } }); can give idea going wrog , should change in code.
to enable mylocationoverlay need call:
mylocationoverlay.enablemylocation(); mmapview.getoverlays().add(mmylocationnewoverlay); in addition remove line code:
mylocationoverlay.disablefollowlocation();
Comments
Post a Comment