java - Can't get overlays to show on own testing app -
edit: man awkward, mker right, corrected code , can see scalebar. no luck yet location issue.
i have been trying few days , i'm starting pull hair. noob @ android , osmdroid.
i can build , have done so, success, osmdroid demo apps. tried osmbonuspack , had navigator working "find me" overlay, scale, etc.
problem whenever make own app, overlay shows , works in map compass. guess doing wrong can't find info on subject.
i have tested genymotion virtual devices (there not compass shows) amd 6.0 mobile compass works, no mylocation or scale.
i have given app permissions, , see in android log messages tiles loading when moving map. plus error haven't found info except in chinese.
e/izatsvc_passiveloclistener: e/exiting error virtual void izat_manager::izatpassivelocationlistener::onlocationchanged(const izat_manager::izatlocation*, izat_manager::izatlocationstatus) line 113 "1"
any welcome!
here manifest.xml:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.anemptyappmap"> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_coarse_location"/> <uses-permission android:name="android.permission.access_fine_location"/> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.read_external_storage" /> <uses-permission android:name="android.permission.write_external_storage" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundicon="@mipmap/ic_launcher_round" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
here mainactivity.java
package com.example.anemptyappmap; import android.content.context; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.displaymetrics; import org.osmdroid.api.imapcontroller; import org.osmdroid.tileprovider.constants.openstreetmaptileproviderconstants; import org.osmdroid.tileprovider.tilesource.tilesourcefactory; import org.osmdroid.util.geopoint; import org.osmdroid.views.mapview; import org.osmdroid.views.overlay.scalebaroverlay; import org.osmdroid.views.overlay.compass.compassoverlay; import org.osmdroid.views.overlay.compass.internalcompassorientationprovider; import org.osmdroid.views.overlay.mylocation.gpsmylocationprovider; import org.osmdroid.views.overlay.mylocation.mylocationnewoverlay; public class mainactivity extends appcompatactivity { //vars para mapa private mylocationnewoverlay mlocationoverlay; private compassoverlay mcompassoverlay=null; //private minimapoverlay mminimapoverlay; private scalebaroverlay mscalebaroverlay; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); context context = getapplicationcontext(); final displaymetrics dm = context.getresources().getdisplaymetrics(); openstreetmaptileproviderconstants.setuseragentvalue(buildconfig.application_id); string cachepath = getcachedir().getabsolutepath(); org.osmdroid.tileprovider.constants.openstreetmaptileproviderconstants.setcachepath(cachepath); //important! set user agent prevent getting banned osm servers //configuration.getinstance().load(ctx, preferencemanager.getdefaultsharedpreferences(ctx)); mapview mmapview = (mapview) findviewbyid(r.id.mmapview); mmapview.settilesource(tilesourcefactory.mapnik); //map.setbuiltinzoomcontrols(true); mmapview.setmultitouchcontrols(true); mlocationoverlay = new mylocationnewoverlay(new gpsmylocationprovider(context),mmapview); mlocationoverlay.enablemylocation(); mlocationoverlay.setdrawaccuracyenabled(true); //mlocationoverlay.setpersonicon(); mlocationoverlay.enablemylocation(); mmapview.getoverlays().add(this.mlocationoverlay); mcompassoverlay = new compassoverlay(context, new internalcompassorientationprovider(context), mmapview); mcompassoverlay.enablecompass(); mmapview.getoverlays().add(this.mcompassoverlay); mscalebaroverlay = new scalebaroverlay(mmapview); mscalebaroverlay.setscalebaroffset(dm.widthpixels / 2, 10); mscalebaroverlay.setcentred(true); mmapview.getoverlays().add(this.mscalebaroverlay); //this.mscalebaroverlay.setalignbottom(true); //this.mscalebaroverlay.setcentred(true); this.mscalebaroverlay.enablescalebar(); //this.mminimapoverlay = new minimapoverlay(); imapcontroller mapcontroller = mmapview.getcontroller(); mapcontroller.setzoom(13); geopoint startpoint = new geopoint(43.3600, -8.2800); mapcontroller.setcenter(startpoint); // mmapview.invalidate(); } }
and layout
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.anemptyappmap.mainactivity"> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/crossfade_content" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <org.osmdroid.views.mapview android:id="@+id/mmapview" android:layout_width="match_parent" android:layout_height="match_parent" /> </linearlayout> </android.support.constraint.constraintlayout>
Comments
Post a Comment