1

Maps are not displayed =(. I use osmdroid libs to display them, and Samsung Tab 2 10.1" for debugging. I tryed to search the problem and most answers were: "you didn't add permission in ur manifest". I added all permissions, but maps, are still not displayed, I also saw, that when some emulators had no SD cards, maps weren't displayed, I have no SD card on my Tablet may be that is the reason. If it is so, what should I do to solve the problem, and if it's not, so what is the real problem then.

I got this main.java

package com.example.tradersamurai;

import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.ResourceProxy;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
import android.view.View;
import android.widget.TextView;


public class MainActivity extends Activity 
{
    // Layout elements
    Button btnAddMark;
    Button btnShowPath;

    TextView tvPathInfo;
    MapView mapView;
    // 

    CityGraph minimap;

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

        // --------------------------------------------------------------------------------------------
        btnAddMark  = (Button) findViewById(R.id.btn_add_mark);
        btnShowPath = (Button) findViewById(R.id.btn_show_path);

        tvPathInfo = (TextView) findViewById(R.id.tv_path_info);
        mapView  = (MapView) findViewById(R.id.mapview);
        mapView.setTileSource(TileSourceFactory.MAPNIK);
        mapView.setBuiltInZoomControls(true);
        mapView.setMultiTouchControls(true);
        mapView.setUseDataConnection(true);

        minimap = new CityGraph();  
    }

    @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 btn_show_path_click(View v)
    {
        tvPathInfo.setText("show path");
    }

    public void btn_add_mark_on_click(View v)
    {
        if(minimap.get_size() + 1 > CityGraph.MAX_SIZE)
            tvPathInfo.setText("Out of range");
        else
        {
            minimap.add_new_vertex();
            tvPathInfo.setText("Added OK");
        }
    }
}

my Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tradersamurai"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <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.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature android:name="android.hardware.location.network" />
    <uses-feature android:name="android.hardware.location.gps" />   
    <uses-feature android:name="android.hardware.wifi" />    

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.tradersamurai.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

and layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/btn_show_path"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_add_mark"
        android:layout_below="@+id/btn_add_mark"
        android:layout_marginTop="24dp"

        android:onClick="btn_show_path_click"       

        android:text="@string/btn_display_path_info_text" />

    <Button
        android:id="@+id/btn_add_mark"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="76dp"
        android:layout_marginTop="35dp"

        android:onClick="btn_add_mark_on_click"

        android:text="@string/btn_add_mark_text" />

    <TextView
        android:id="@+id/tv_path_info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn_show_path"
        android:layout_below="@+id/btn_show_path"
        android:layout_marginTop="46dp"
        android:text="@string/tv_path_info" />

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="800dp"
        android:layout_height="fill_parent"
        android:layout_centerVertical="true"
        android:clickable="true" >

    </org.osmdroid.views.MapView>

</RelativeLayout>
theroom101
  • 599
  • 1
  • 9
  • 23
  • 2
    See http://stackoverflow.com/questions/21191767/osmdroid-and-mapnik-tile-provider-no-longer-working – NickT Jan 20 '14 at 21:12
  • Does it show at least the grid or nothing at all ? If the grid is shown, the problem is in the provider, it doesn't download the tiles properly. – Mehdiway Jan 21 '14 at 16:02
  • 2
    Grid is shown. I solve this problem by replacing mapView.setTileSource(TileSourceFactory.MAPNIK); to mapView.setTileSource(TileSourceFactory.MAPQUESTOSM); – theroom101 Jan 22 '14 at 12:34
  • doesn't work anymore – Leo DroidCoder Aug 10 '16 at 21:49

0 Answers0