2011-11-23 1 views
5

Android 앱 개발에 익숙하지 않아 오프라인지도 Android 애플리케이션을 만들어야합니다.Android에서 오프라인지도 만들기

맵지도보기 osmdroid .zip 형식을 얻기 위해 모바일 아틀라스 크리에이터를 사용했으며, 앱에 추가하는 방법을 모르겠습니다.

누군가 내 앱에서 Osmdroid 사용법을 보여 줄 수 있습니까? 단계별 지침을 제공 할 수 있다면 고맙겠습니다.

답변

4

이것은 내가 언젠가 만든 Osmdroid를위한 절대적인 최소 예제 프로젝트입니다.

package osmdemo.demo; 

import org.osmdroid.tileprovider.tilesource.TileSourceFactory; 
import org.osmdroid.util.GeoPoint; 
import org.osmdroid.views.MapController; 
import org.osmdroid.views.MapView; 

import android.app.Activity; 
import android.os.Bundle; 

// This is all you need to display an OSM map using osmdroid 
public class OsmdroidDemoMap extends Activity { 

    private MapView   mMapView; 
    private MapController mMapController; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.osm_main); 
     mMapView = (MapView) findViewById(R.id.mapview); 
     mMapView.setTileSource(TileSourceFactory.MAPNIK); 
     mMapView.setBuiltInZoomControls(true); 
     mMapController = mMapView.getController(); 
     mMapController.setZoom(13); 
     GeoPoint gPt = new GeoPoint(51500000, -150000); 
     //Centre map near to Hyde Park Corner, London 
     mMapController.setCenter(gPt); 
    } 
} 

osm_main.xml

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

빌드 경로에 slf4j-android-1.5.8.jarosmdroid-android-3.0.5.jar을 포함하여이 되세요. (어디에서 얻을 수 있는지에 대한 Google 검색)

+0

thx 답변 모바일 아틀라스 크리에이터에서 추출한보기를 호출하는 방법 또는 자동으로 표시 할 수 있습니까? – Adams

+1

그것은 자동이다, 당신의 전화에 폴더/sdcard/osmdroid에 zip 파일을 그냥 내 보낸다. – NickT

+0

thx NickT 그것이 작동했는지 어느 폴더에있는 시뮬레이터에 내게 말해 줄 수 있니? .zip thx – Adams