java - opening offline tiles in Osmdroid -
i trying develop offline map using osmdroid , trying use mbtiles created mobile atlas creator every-time open application crashes. here main activity code. when use normal jpg file load tiles, works fine no use cannot bound maps.
package com.maptry.katgp; import java.io.file; import java.util.arraylist; import org.osmdroid.defaultresourceproxyimpl; import org.osmdroid.resourceproxy; import org.osmdroid.api.imapcontroller; import org.osmdroid.tileprovider.iregisterreceiver; import org.osmdroid.tileprovider.tilesource.xytilesource; import org.osmdroid.util.boundingboxe6; import org.osmdroid.util.geopoint; import org.osmdroid.views.mapcontroller; import org.osmdroid.views.mapview; import org.osmdroid.views.overlay.overlayitem; import android.os.bundle; import android.os.environment; import android.app.activity; public class mainactivity extends activity implements iregisterreceiver { // initializing mapview mapview mapview; // private mapcontroller mapcontroller; // arraylist<overlayitem> anotheroverlayitemarray; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // contents main setcontentview(r.layout.activity_main); // connecting xml layout id mapview = (mapview) findviewbyid(r.id.mapview); // setting default online tiles // mapnik not working replaced mapquest // online use // mapview.settilesource(tilesourcefactory.mapquestosm); //adding offline tiles using mbtiles defaultresourceproxyimpl resproxy; resproxy = new defaultresourceproxyimpl(this.getapplicationcontext()); file file = new file(environment.getexternalstoragedirectory(), "maptile.mbtiles"); mbtileprovider provider = new mbtileprovider(this, file); boundedmapview mapview = new boundedmapview(this, resproxy, provider); double north = 27.749177; double east = 85.382652; double south = 27.648864; double west = 85.262489; boundingboxe6 bbox = new boundingboxe6(north, east, south, west); mapview.setscrollablearealimit(bbox); /* * // adding offline tiles * * mapview.settilesource(new xytilesource("mapquest", * resourceproxy.string.mapquest_osm, 13, 18, 256, ".jpg", new string[] * { "http://otile1.mqcdn.com/tiles/1.0.0/map/", * "http://otile2.mqcdn.com/tiles/1.0.0/map/", * "http://otile3.mqcdn.com/tiles/1.0.0/map/", * "http://otile4.mqcdn.com/tiles/1.0.0/map/" })); */ // zooming , multitouch controls mapview.setbuiltinzoomcontrols(true); mapview.setmultitouchcontrols(true); mapview.setusedataconnection(false); mapcontroller controller = mapview.getcontroller(); controller.setzoom(12); controller.animateto(new geopoint(27.7, 85.32)); }
}
Comments
Post a Comment