Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

OSMdroid ni o`zimni dasturimga qanday ulasam bo`ladi?

+3 ovoz
68 marta ko‘rilgan
so‘radi 04 fevral, 17 Bilmasvoy (904 bal)

Android'da programma yasayotgan edim. Google kartasini o`rniga OSM kartasini qo`yishim kerak bo`lmoqda. 

Men qilgan urinishlar:

dependencies {
    compile 'org.osmdroid:osmdroid-android:5.6.3'
}

qo`shdim, va activity yasadim

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
        setContentView(R.layout.activity_main);

        MapView map = (MapView) findViewById(R.id.map);
        // map.setTileSource(TileSourceFactory.MAPNIK);
        map.setTileSource(TileSourceFactory.MAP_OSM_OZIMNIKI);
    }

    public void onResume(){
        super.onResume();
        Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
    }
}

Karta bo`sh chiqvotti. Muammo 

TileSourceFactory.MAP_OSM_OZIMNIKI

da ekanini chundim, shu MAP_OSM_OZIMNIKI obyekni qanday bo`lishi kerak?

Yoki kodimda xato bormi?

izoh qoldirdi 16 mart, 17 Axrorxo'ja (743 bal)
offline mapni mobac orqali qilganmisiz

2 Javoblar

+1 ovoz
javob berdi 04 fevral, 17 Saidolim (3,546 bal)
tanlangan 04 fevral, 17 Bilmasvoy
 
Eng yaxshi javob

Bitta yangi class yasang, kartalarni saqlash uchun. Masalan,

public class MyLocalMaps {
    public static final OnlineTileSourceBase MAP_OSM_OZIMNIKI = new XYTileSource("Osm Ozimniki", 0, 19, 256, ".png", new String[]{"http://osm.ozimniki.uz/tiles/"}, "© Osm Ozimniki");
}

keyin esa, kartani configini quyidagicha qilasiz:

// map.setTileSource(TileSourceFactory.MAPNIK);
map.setTileSource(MyLocalMaps.MAP_OSM_OZIMNIKI);
izoh qoldirdi 04 fevral, 17 Bilmasvoy (904 bal)
Ishlatdim rahmat !!!
+1 ovoz
javob berdi 04 fevral, 17 Faxriddin (823 bal)

Agar siz Android studioda ishlayotgan bo'lsangiz Gradle dependency katalogiga quyidagi kodni qo'shing

repositories {
        mavenCentral()
}

dependencies {
    compile 'org.osmdroid:osmdroid-android:5.6.3'
}

Maven dependency

<dependency>
  <groupId>org.osmdroid</groupId>
  <artifactId>osmdroid-android</artifactId>
  <version>5.6.3</version>
  <type>aar</type>
</dependency>

Android AOI >= 8 bo'lishi kerak

Android Manifestga quyidagi permissionlarni qo'shing
<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" />

Quyidagicha layout fayl yarating
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <org.osmdroid.views.MapView android:id="@+id/map"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" />
</LinearLayout>

MainActivityga quyidagi kodni kiriting
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.views.MapView;

public class MainActivity extends Activity {
    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //important! set your user agent to prevent getting banned from the osm servers  
        Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
        setContentView(R.layout.activity_main);

        MapView map = (MapView) findViewById(R.id.map);
        map.setTileSource(TileSourceFactory.MAPNIK);
    }

    public void onResume(){
        super.onResume();
        //this will refresh the osmdroid configuration on resuming.
        //if you make changes to the configuration, use 
        //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        //Configuration.getInstance().save(this, prefs);
        Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
    }
}

qoshimcha malumot https://github.com/osmdroid/osmdroid/wiki/How-to-use-the-osmdroid-library urldan olishingiz mumkun.
izoh qoldirdi 04 fevral, 17 Bilmasvoy (904 bal)
Bularni hammasini qildim. TileSourceFactory.MAPNIK ni o`rniga o`zimni kartamni ishlatmoqchi edim. Shunga nima yozishni bilmi turimman

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...