java - Error while following osmbonuspack "Hello, Routing World!" tutorial -
i have created simple project using osm.the map showing current location. want create navigation current location specific point on map.i trying follow this tutorial.
in polyline roadoverlay = roadmanager.buildroadoverlay(road, this); line,i getting error
type mismatch: cannot convert pathoverlay polyline
i using following libraries in project:
1. osmdroid-android-4.1.jar 2. osmbonuspack_3.0.jar 3. slf4j-android-1.5.8.jar
here mainactivity:
import java.util.arraylist; import org.osmdroid.defaultresourceproxyimpl; import org.osmdroid.resourceproxy; import org.osmdroid.api.polyline; import org.osmdroid.bonuspack.routing.osrmroadmanager; import org.osmdroid.bonuspack.routing.road; import org.osmdroid.bonuspack.routing.roadmanager; import org.osmdroid.tileprovider.tilesource.tilesourcefactory; import org.osmdroid.util.geopoint; import org.osmdroid.views.mapview; import android.app.activity; import android.graphics.drawable.drawable; import android.os.bundle; import android.view.menu; public class mainactivity extends activity { myitemizedoverlay myitemizedoverlay = null; double latitude; double longitude; // mapview variable: private mapview m_mapview; geopoint startpoint; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); gpstracker tracker = new gpstracker(this); if (tracker.cangetlocation() == false) { tracker.showsettingsalert(); } else { latitude = tracker.getlatitude(); longitude = tracker.getlongitude(); } // find mapview controller in layout: m_mapview = (mapview) findviewbyid(r.id.mapview); //mapview mapview = new mapview(this, 256); //constructor m_mapview.setclickable(true); m_mapview.setbuiltinzoomcontrols(true); //setcontentview(m_mapview); //displaying mapview m_mapview.settilesource(tilesourcefactory.mapquestosm); m_mapview.getcontroller().setzoom(15); //set initial zoom-level, depends on need m_mapview.getcontroller().setcenter(new geopoint(latitude, longitude)); m_mapview.setusedataconnection(true); m_mapview.setmultitouchcontrols(true); drawable marker = getresources().getdrawable(r.drawable.pin_for_map); int markerwidth = marker.getintrinsicwidth(); int markerheight = marker.getintrinsicheight(); marker.setbounds(0, markerheight, markerwidth, 0); resourceproxy resourceproxy = new defaultresourceproxyimpl( getapplicationcontext()); myitemizedoverlay = new myitemizedoverlay(marker, resourceproxy); m_mapview.getoverlays().add(myitemizedoverlay); geopoint mypoint1 = new geopoint(latitude, longitude); myitemizedoverlay.additem(mypoint1, "mypoint1", "mypoint1"); startpoint = new geopoint(latitude, longitude); } //for routing public void osmroute() { //road manager roadmanager roadmanager = new osrmroadmanager(); //start , end points arraylist<geopoint> waypoints = new arraylist<geopoint>(); waypoints.add(startpoint); geopoint endpoint = new geopoint(48.4, -1.9); waypoints.add(endpoint); //etreive road between points road road = roadmanager.getroad(waypoints); //build polyline route shape polyline roadoverlay = roadmanager.buildroadoverlay(road, this); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
here activity_main.xml:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <org.osmdroid.views.mapview android:id="@+id/mapview" android:layout_width="match_parent" android:layout_height="match_parent" android:enabled="true" android:clickable="true" /> </relativelayout>
where going wrong? should complete tutorial?
in addition kurtzmarc comment, not using correct version of osmbonuspack:
if using osmdroid-android-4.1.jar, must use osmbonuspack v4.2.6 or above.
download latest version (v4.4), not outdated one.
Comments
Post a Comment