首页 文章 精选 留言 我的

精选列表

搜索[android things],共10000篇文章
优秀的个人博客,低调大师

Android GIS开发系列-- 入门季(15) 网络图层加载

一、首先我们来看一个网络图层: http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer,这是全球街道图。加载的代码也很简单: private static final String WORLD_STREETS_URL = "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; private MapView mMapView = null; private ArcGISTiledMapServiceLayer mWorldStreetsLayer = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMapView = (MapView) findViewById(R.id.map_view); mWorldStreetsLayer = new ArcGISTiledMapServiceLayer(WORLD_STREETS_URL); mMapView.addLayer(mWorldStreetsLayer); mWorldStreetsLayer.setOnStatusChangedListener(new OnStatusChangedListener() { @Override public void onStatusChanged(Object o, STATUS status) { if (status==STATUS.INITIALIZED){ Log.i("huang","加载成功"); }else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){ Log.i("huang","加载失败"); } } }); } 效果图 问:为什么用ArcGISTiledMapServiceLayer 加载而不用其他图层加载呢? 用浏览器打开http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer,可以看到详细信息。 它的子图层只有一个: 下面是坐标信息,注意Single Fused Map Cache: true,支持缓存。 与Tile Info信息, 通过信息说明这是一个TiledLayer,而ArcGISTiledMapServiceLayer是TiledLayer子类的子类,看一下ArcGISTiledMapServiceLayer的介绍。 点开World Street Map链接,http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/0,这是它的唯一子图层。真正加载的也是这个图层 Type虽然说是FeatureLayer,但它得用ArcGISFeatureLayer加载。 ArcGISFeatureLayer arcGISFeatureLayer = new ArcGISFeatureLayer(WORLD_STREETS_URL+"/0", ArcGISFeatureLayer.MODE.ONDEMAND); SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(Color.argb(0,0,0,0),SimpleFillSymbol.STYLE.SOLID); mMapView.addLayer(arcGISFeatureLayer); arcGISFeatureLayer.setRenderer(new SimpleRenderer(simpleFillSymbol)); arcGISFeatureLayer.setOnStatusChangedListener(new OnStatusChangedListener() { @Override public void onStatusChanged(Object o, STATUS status) { if (status==STATUS.INITIALIZED){ Log.i("huang","加载成功"); }else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){ Log.i("huang","加载失败"); } } }); 上面虽然加载成功,但并看不到图层,而且报错: FeatureSetCallback.onError com.esri.core.io.EsriServiceException: Requested operation is not supported by this service. The requested capability is not supported. 仔细再看网络信息, 大体上知道为什么报 The requested capability is not supported。也就是不能用这种方法加载,而得用前面的代码加载!!! ArcGISDynamicMapServiceLayer 服务地址:http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer,这是美国的高铁图。 用浏览器打开,有三个子图层,Single Fused Map Cache: false! 下面是ArcGISDynamicMapServiceLayer的介绍: 加载代码 : private static final String DYNAMIC_USA_HIGHWAY_URL = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"; private ArcGISDynamicMapServiceLayer usaHighwayLayer = null; private MapView mMapView = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mMapView = (MapView) findViewById(R.id.map_view); usaHighwayLayer = new ArcGISDynamicMapServiceLayer(DYNAMIC_USA_HIGHWAY_URL); mMapView.addLayer(usaHighwayLayer); usaHighwayLayer.setOnStatusChangedListener(new OnStatusChangedListener() { @Override public void onStatusChanged(Object o, STATUS status) { if (status==STATUS.INITIALIZED){ Log.i("huang","加载成功"); }else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){ Log.i("huang","加载失败"); } } });} 效果图 二、ArcGISFeatureLayer加载图层 服务地图http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0,也就是上面服务的子图层。 ArcGISFeatureLayer arcGISFeatureLayer = new ArcGISFeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0", ArcGISFeatureLayer.MODE.ONDEMAND); mMapView.addLayer(arcGISFeatureLayer); arcGISFeatureLayer.setRenderer(new SimpleRenderer(new SimpleLineSymbol(Color.argb(250, 52, 17, 255),2))); arcGISFeatureLayer.setOnStatusChangedListener(new OnStatusChangedListener() { @Override public void onStatusChanged(Object o, STATUS status) { if (status==STATUS.INITIALIZED){ Log.i("huang","加载成功"); }else if(status==STATUS.INITIALIZATION_FAILED||status==STATUS.LAYER_LOADING_FAILED){ Log.i("huang","加载失败"); } } }); 注意要设置setRenderer,效果 ArcGISFeatureLayer 具有FeatureLayer的一些查询方法,与前面几讲里FeatureLayer查询相似,这里不再讲了。 //查询要素方法 queryIds(Query query, CallbackListener<int[]> callback) queryFeatures(Query query, CallbackListener<FeatureSet> callback) 在http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/0,页面底部, 点击Query进入查询要素界面,可直接 查询要素 where 1=1,点击Query(GET),可得到以下结果集 没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。 本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/7752063.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

android 4.4 支持透明状态栏和透明导航栏

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } setContentView(R.layout.activity_main); } 本文转自 netcorner 博客园博客,原文链接:http://www.cnblogs.com/netcorner/p/4781253.html ,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

用户登录
用户注册
修改密码
忘记密码