samavedulark / osmbonuspack

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

Issue loading previously created tiles from MapquestOSM folder #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Trying to load previously download maptiles from /sdcard/osmdroid/ folder
2. Trying to use my app offline

What is the expected output? What do you see instead?

The tiles should be loaded offline in the absence of internet connectivity, but 
when there is no internet connectivity no map is loading.

What version of the products are you using (Android SDK, osmdroid,
OSMBonusPack)?

osmdroid-android-4.1.jar
osmbonuspack_v4.4.jar
eclipse android sdk

Please provide any additional information below.

I have create a simple OSM Map application for offline viewing and navigation. 
While creating the app, I followed the following tutorials:

http://mobiledevstories.wordpress.com/page/2/
http://www.haakseth.com/?p=30

The application is working fine when Internet connectivity is working. But, 
when there is not internet connection, the app should load tiles from the 
/sdcard/osmdroid/ folder which is not happening. No tiles are getting loaded 
when I am offline.

My main intention is to allow the users to download tiles of different cities 
from the internet and use them later when they do not have internet 
connectivity.

The activity which I have created:

public class MainActivity extends Activity {

    double myCurrentLatitude;
    double myCurrentLongitude;

    // The MapView variable:
    MapView mapView;

    List<Overlay> mapOverlays;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // get current location
        GPSTracker tracker = new GPSTracker(this);
        if (tracker.canGetLocation() == false) {
            tracker.showSettingsAlert();
        } else {
            myCurrentLatitude = tracker.getLatitude();
            myCurrentLongitude = tracker.getLongitude();
        }

        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setClickable(true);
        // mapView.setBuiltInZoomControls(true);
        // for only pinch zoom
        mapView.setMultiTouchControls(true);
        mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
        mapView.getController().setZoom(15);
        mapView.getController().setCenter(
                new GeoPoint(myCurrentLatitude, myCurrentLongitude));

//      mapView.getController().setCenter(
//              new GeoPoint(18.9750, 72.8258));

        mapOverlays = mapView.getOverlays();

        showMyCurrentLocation();
        showFoodJoint("1",22.5850, 88.3750, "Test food", "Maniktala");
        showFoodJoint("2",22.576600900000000000, 88.367032500000050000, "Test food 2", "College Street");

        // =====For showing restaurant location on
        // map======================//

    }

    // =====For showing my current location on map======================//
    public void showMyCurrentLocation() {
        Drawable myLocationDrawable = this.getResources().getDrawable(
                R.drawable.pin_for_my_location);

        MapItemizedOverlay itemizedoverlayForMyLocation = new MapItemizedOverlay(
                myLocationDrawable, this);
        itemizedoverlayForMyLocation.setEnabled(true);

        itemizedoverlayForMyLocation.setEnabled(true);

        // setting pin to my current position on the map

        GeoPoint myCurrentPoint = new GeoPoint(myCurrentLatitude,
                myCurrentLongitude);
//      GeoPoint myCurrentPoint = new GeoPoint(18.9750,
//              72.8258);
        OverlayItem overlayitem = new OverlayItem("Id","Hello", "You are here",
                myCurrentPoint);

        itemizedoverlayForMyLocation.addOverlay(overlayitem);

        mapOverlays.add(itemizedoverlayForMyLocation);

        mapView.getController().setZoom(15);
        mapView.getController().setCenter(myCurrentPoint);
    }

    // =====For showing my current location on map======================//

    // =====For showing restaurant location======================//
    public void showFoodJoint(String foodJointId,double foodJointLat, double foodJointLon, String foodJointName, String foodJointDescription)
    {
        Drawable restaurantLocationDrawable = this.getResources().getDrawable(
                R.drawable.pin_for_restaurant_location);
        MapItemizedOverlay itemizedoverlayForRestaurant = new MapItemizedOverlay(
                restaurantLocationDrawable, this);

        GeoPoint myPoint1 = new GeoPoint(foodJointLat, foodJointLon);
        OverlayItem overlayitem2 = new OverlayItem(foodJointId,foodJointName,foodJointDescription, myPoint1);

        itemizedoverlayForRestaurant.addOverlay(overlayitem2);

        mapOverlays.add(itemizedoverlayForRestaurant);
    }

    // =====For showing restaurant location======================//

    // For routing

    // ======================================================================================================
    /**
     * Add a route overlay between two geopoints with Bubble overlays on the
     * route points.
     * 
     * @param startPoint
     *            Route start.
     * @param endPoint
     *            Route end.
     */
    // ======================================================================================================
    public void addRouteOverlay(GeoPoint startPoint, GeoPoint endPoint) {
        // road manager
        RoadManager roadManager = new OSRMRoadManager();

        // start and end points
        ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
        waypoints.add(startPoint);
        // GeoPoint endPoint = new GeoPoint(48.4, -1.9);
        waypoints.add(endPoint);
        // roadManager.addRequestOption("routeType=bicycle");
        // retreive the road between those points
        Road road = roadManager.getRoad(waypoints);
        // Polyline with the route shape
        org.osmdroid.bonuspack.overlays.Polyline roadOverlay = RoadManager
                .buildRoadOverlay(road, this);
        // Polyline to the overlays of your map
        mapView.getOverlays().add(roadOverlay);
        // Refresh the map
        mapView.invalidate();

    }// ===================================================================================================

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

public void makeAToast(String str) {
        Toast toast = Toast.makeText(this, str, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }

}

Where am I going wrong?

Original issue reported on code.google.com by androabh...@gmail.com on 14 Jun 2014 at 5:00

GoogleCodeExporter commented 9 years ago
This is related to osmdroid, not to OSMBonusPack.  
So you should raise it in osmdroid issues, or on StackOverflow. 

However, before raising a new issue somewhere, have a look here: 
http://stackoverflow.com/questions/22862534/download-maps-for-osmdroid/22868462#
22868462

, as it probably describes your issue, and its solution. 

Original comment by mathieu....@gmail.com on 14 Jun 2014 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by mathieu....@gmail.com on 21 Jun 2014 at 3:31