离线地图使用ArcGIS android SDK [英] Offline Map using ArcGIS android SDK

查看:55
本文介绍了离线地图使用ArcGIS android SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ArcGis android sdk 开发离线地图应用程序.按照 ArcGis 网站上的教程进行操作.由于它是离线地图应用程序,因此我在没有 Internet 连接的情况下对其进行了测试.但是,当我运行应用程序时,MapView 是空白的.它只是显示一个黑屏.当我检查 Logcat 时,它说

I'm trying to develop an Offline maps application using ArcGis android sdk. Followed the tutorials from the ArcGis website.Since it is an Offline Maps Applicaion, I am testing it without an internet connection. But, when I run the application,the MapView is blank. It just shows a black screen. When I checked the Logcat, It says

11-26 14:39:57.757 28520-28520/com.example.lalprakash.offlinearcgismap D/GLSurfaceView: checkGLSurfaceViewlLogProperty get invalid command
11-26 14:39:57.839 28520-28548/com.example.lalprakash.offlinearcgismap I/System.out: httpget:http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer?f=json
11-26 14:39:57.840 28520-28548/com.example.lalprakash.offlinearcgismap I/System.out: http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer?f=json
11-26 14:39:57.846 28520-28548/com.example.lalprakash.offlinearcgismap I/System.out: [CDS][DNS]Unable to resolve host "server.arcgisonline.com": No address associated with hostname
11-26 14:39:57.846 28520-28548/com.example.lalprakash.offlinearcgismap E/ArcGIS: url =http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer
11-26 14:39:57.884 28520-28520/com.example.lalprakash.offlinearcgismap V/PhoneWindow: DecorView setVisiblity: visibility = 4 ,Parent =null, this =com.android.internal.policy.impl.PhoneWindow$DecorView{41ce4470 I.E..... R.....ID 0,0-0,0}
11-26 14:39:57.891 28520-28520/com.example.lalprakash.offlinearcgismap V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{41d35928 com.example.lalprakash.offlinearcgismap/com.example.lalprakash.offlinearcgismap.MainActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{41ce4470 V.E..... R.....ID 0,0-0,0}

我无法理解对 server.arcgisonline.com 的请求从何而来.我的java文件和xml文件如下

I can't understand from where, a request to server.arcgisonline.com is going. My java file and xml file are as follows

MainActivity.java

public class MainActivity extends Activity {

    MapView mMapView;
    String extern = Environment.getExternalStorageDirectory().getPath();
    final String tpkPath = "/ArcGIS/samples/OfflineRouting/ImageryTPK.tpk";
    TiledLayer mTileLayer;
    GraphicsLayer mGraphicsLayer = new GraphicsLayer(GraphicsLayer.RenderingMode.DYNAMIC);

    RouteTask mRouteTask = null;
    NAFeaturesAsFeature mStops = new NAFeaturesAsFeature();

    Locator mLocator = null;

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

        mTileLayer = new ArcGISLocalTiledLayer(extern + tpkPath);
        // Retrieve the map and initial extent from XML layout
        mMapView = (MapView) findViewById(R.id.map);

        // Set the tiled map service layer and add a graphics layer
        mMapView.addLayer(mTileLayer);
        mMapView.addLayer(mGraphicsLayer);
    }

}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.esri.android.map.MapView
        android:id="@+id/map"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        initExtent = "-1.3296373526814876E7 3930962.41823043 -1.2807176545789773E7 4201243.7502468005"
        mapoptions.MapType="Topo"
        mapoptions.ZoomLevel="16" />
</RelativeLayout>

build.gradle如下

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.lalprakash.offlinearcgismap"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        sourceSets.main{
            jniLibs.srcDir 'src/main/jni'
            jni.srcDirs=[]
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/arcgis-android-api.jar')
    compile files('libs/arcgis-android-app-toolkit.jar')
    compile files('libs/jackson-all-1.9.0.jar')
}

此外,我已将 tpk 文件放在我的内存根目录中.请帮助我,因为我非常需要它.谢谢.

Also, I've placed the tpk file in the root of my internal memory. Please help me as I need it really badly. Thank you.

推荐答案

你能否从你的 XML 中删除 initextent 和 mapoption.maptype 并告诉我发生了什么.我还没有机会看看你的堆栈跟踪但是这个应该在你的屏幕上显示你的地图

can you remove the initextent and mapoption.maptype from ur XML and tell me what happens.i havent got the chance to take a look at ur stack trace but this should show u ur map on ur screen

这篇关于离线地图使用ArcGIS android SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆