(一)安装环境配置

① 去官网下载SCGIS API for Android V2.0

② 将安装目录下的scmapapi.aar包拷到项目libs文件夹中

将安装目录下的assets文件拷贝到app/src/main文件目录下

③ 打开内部的build文件,在dependencies下添加如下内容:

compile(name: 'scmapapi', ext: 'aar')

compile 'com.esri.arcgis.android:arcgis-android:10.2.9'

(因为天地图要集成arcgis,故要添加arcgis的jar包)

④ 打开外部的build文件,在repositories 下添加如下内容:

url 'https://esri.bintray.com/arcgis'

(二)加载地图服务

首先你要了解图层,我这里把他写成一个公共的方法

/*** 加载地图* @param context:上下文对象* @param mMapView:地图控件* @param comX:中心点x的坐标(实际上就是经纬度)* @param comY*/public static void loadmap(Context context,MapView mMapView,double comX,double comY,double resolution){SCGISTiledMapServiceLayer mDLGTileMapServiceLayer = null;ArcGISRuntime.setClientId("CfIG4r7FQDyeNuii");//实现切片缓存管理器TileCacheDBManager mDLGTileDBManager = new TileCacheDBManager(context, "CTZK_freeTrade.db");//实例化地图切片图层if(mDLGTileMapServiceLayer == null){mDLGTileMapServiceLayer = new SCGISTiledMapServiceLayer(context, CountOfStatic.dlgUrl,true, mDLGTileDBManager);}//切片图层的缓冲文件大小设为100MmDLGTileMapServiceLayer.setCacheSize(100);//设置瓦片压缩比例mDLGTileMapServiceLayer.setTileCompressAndQuality(true,70);//实例化动态地图服务图层mMapView.addLayer(mDLGTileMapServiceLayer);//设置缩放比例---0.000006328125mMapView.setResolution(resolution);//已数据库中存储的公司的地址为中心Point point = new Point(comX, comY);mMapView.centerAt(point, true);}

(三)添加图层服务

图层是一层一层添加的,后面的会把前面的给覆盖了,同样我抽了一个公共的方法

在这里要强调的是GraphicsLayer最好是传过来的,方便在其他代码里对图层进行操作

/** * 加载一个新的图层 * @param context * @param mMapView * @param mGraphicsLayer * @param tagOfImg:新图层标注的图片的id * @param point:新图层画的位置 */  public static void makeLayer(Context context,MapView mMapView,GraphicsLayer mGraphicsLayer,int tagOfImg,Point point){  //设置标注---新建一个图层  //定义一个GraphicsLayer并将之加入到map  mMapView.addLayer(mGraphicsLayer);  //定义一个PictureMarkerSymbol用来设置位置显示的样式  PictureMarkerSymbol mPictureMarkerSymbol = new PictureMarkerSymbol(context.getResources().getDrawable(tagOfImg));mGraphicsLayer.removeAll(); mGraphicsLayer.addGraphic(graphicPoint); }  

(四)气泡的生成(callout)
① 加载自定义气泡,这里传进去的view就是自己自定义的布局,我这里就是一个简单的排版,在代码下附.xml文件
(加载步骤我就不写了,适配数据也省了,大概就是核心就是这样,如果你要适配特定的数据,添加气泡里面可以直接用view把你需要的控件findviewbyId出来,然后再给他设置数据就可以了)

/*** 添加气泡*/private void addCallout(Point point,View view) {//获取一个气泡callout = mMapView.getCallout();// 获取CalloutCallout callout = mMapView.getCallout();callout.setContent(view);// 设置Callout样式// callout.setStyle(R.xml.callout_stytle);// 设置锚点偏移量callout.setOffset(0, -5);callout.show(point,view);}
<!--气泡的布局-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@drawable/border_callout"android:padding="10dp"android:gravity="center_vertical"><TextViewandroid:id="@+id/shpoName"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="店铺的名称"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:textColor="#000"android:textSize="17sp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginTop="10dp"android:orientation="horizontal"android:gravity="center_vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="地址:"android:textColor="#9000"android:textSize="16dp"/><TextViewandroid:id="@+id/quName"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:id="@+id/countryName"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"/><TextViewandroid:id="@+id/roudeName"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:lines="1"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginTop="10dp"android:orientation="horizontal"android:gravity="center_vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="电话:"android:textColor="#9000"android:textSize="16dp"/><TextViewandroid:id="@+id/phone"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:text="暂无点电话"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="right"android:layout_gravity="right"android:layout_margin="10dp"><TextViewandroid:id="@+id/goHere"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="5dp"android:text="到这里去"android:gravity="right"android:paddingRight="20dp"android:background="@drawable/background_login_press"android:textColor="#000"android:paddingBottom="5dp"android:paddingTop="5dp"android:paddingLeft="20dp"/></LinearLayout>
</LinearLayout>

② 只有点击特定的位置的点才会弹出气泡
这里的nameSearchLayer就是呢个特定位置的图

/*** 地图的点击事件*/private class SigleTapListener implements OnSingleTapListener {@Overridepublic void onSingleTap(float v, float v1) {int[] graphicIDs = nameSearchLayer.getGraphicIDs(v, v1, 25);if (graphicIDs != null && graphicIDs.length > 0) {LayoutInflater inflater = LayoutInflater.from(POIActivity.this);View view = inflater.inflate(R.layout.item_callout_poi,null);if(nameSearchLayer != null){Graphic graphic = nameSearchLayer.getGraphic(graphicIDs[0]);Map<String, Object> attributes = graphic.getAttributes();name_1 = (String) attributes.get("name");String addr = (String) attributes.get("addr");String phone = (String) attributes.get("phone");String region = (String) attributes.get("region");String county = (String) attributes.get("county");TextView shopName = view.findViewById(R.id.shpoName);TextView countryName = view.findViewById(R.id.countryName);TextView quName = view.findViewById(R.id.quName);TextView roudeName = view.findViewById(R.id.roudeName);TextView phone1 = view.findViewById(R.id.phone);goHere = view.findViewById(R.id.goHere);goHere.setOnClickListener(new onClickListener());shopName.setText(name_1);changeAddr_edit.setText(name_1);countryName.setText(county);quName.setText(region);roudeName.setText(addr);if(TextUtils.isEmpty(phone)){phone = "暂无电话";}phone1.setText(phone);Point p = (Point) graphic.getGeometry();x=p.getX();y=p.getY();//获取一个气泡callout = mMapView.getCallout();//设置样式callout.setStyle(R.xml.callout_stytle);callout.setOffset(0,5);callout.show((Point)graphic.getGeometry(),view);}else{return;}}else{if(callout != null){callout.hide();}}}}

ArcGis for Android 集成天地图四川(一)相关推荐

  1. android天地图使用,ArcGIS for android访问天地图

    底图采用Web Mercator投影坐标系 获取元数据信息: http://t0.tianditu.com/img_w/wmts?SERVICE=WMTS&REQUEST=GetCapabil ...

  2. arcgis for Android 100.1 在线加载天地图和谷歌地图

    距离上一篇arcgis for Android 已经很久.其实年初的时候就测试了arcgis for Android 100.1版本.搜集网上各篇文章,最后自已测试代码.修改代码.这一篇来讲一下加载在 ...

  3. arcgis for android(五)加载天地图

    1.上一篇文章arcgis for android 入门与提高(四)去掉属性标记和水印arcgis for android 入门与提高(四)去掉属性标记和水印_郝大大的博客-CSDN博客,接下来介绍国 ...

  4. arcgis for android离线编辑,ArcGIS for Android离线数据编辑实现原理

     实现ArcGIS for Android上的离线数据编辑,具体实现环境及其步骤如下: 一.      环境准备 1.        软件环境 1)        ArcGIS Server10用 ...

  5. arcgis for Android 100.2 绘制点线面(文末有三维地图)

    这是这阶段arcgis for Android 的最后一篇了,前面有三篇.对于我经常使用坐标,进行绘制点线面图形的程序员,这个必须要的.因为在项目中经常用到. arcgis for Android 1 ...

  6. arcgis for android(六)定位

    1.上一节讲了如何加载天地图arcgis for android 入门与提高(五)加载天地图arcgis for android 入门与提高(五)加载天地图_郝大大的博客-CSDN博客_android ...

  7. mmpk文件的打包与加载(ArcGIS for Android 100.x)

    一.mmpk文件的生成 移动地图包是一个以".mmpk"结尾的单独文件扩展,它可以将你的组织的maps.资源.道路网.或者坐标集成到一个文件.根据这些数据你的用户就可以清楚自己的方 ...

  8. Arcgis For Android之离线地图实现的几种方式

    一. 在Arcgis For Android API下,既能加载Arc Server的切片文件,也能加载10.1的Title Package文件(*.tpk). 一般来说,我们都是将Server的切片 ...

  9. 视频教程-初级学习ArcGis for Android 视频课程-Android

    初级学习ArcGis for Android 视频课程 从事软件开发10年,熟悉软件开发流程,精通WEB系统程序开发.先后参与水利厅,环保厅,国税局,国土资源厅等重大项目的建设.精通地理信息系统研发, ...

最新文章

  1. python读取文件特定内容_python读取指定内存的内容
  2. ML之监督学习算法之分类算法一 ———— k-近邻算法(最邻近算法)
  3. 【luogu 3811】【模板】乘法逆元
  4. 员工工号怎么编码_华为员工感慨:工号就留在这了,感谢公司给我自己写墓志铭的机会...
  5. 多线程环境下的线程不安全问题(1)
  6. Flask-SQLALchemy 连接数据库
  7. 深入分析FreeDos -- 前言
  8. ZetCode Spring 教程
  9. Android学习笔记06---电话拨号器的制作:项目结构深化
  10. IMF:央行须变得更像苹果公司以保证央行数字货币处在技术前沿
  11. 切换回Chrome上的上次标签及打开设置快捷键
  12. 苹果自动驾驶测试车近距离实拍,头顶新添传感器和硬件
  13. Excel 中 查看 当前列 最后一个不为空的值 (使用公式实现)
  14. SQL Server 删除数据表数据
  15. 天天学习: 关于美资,台资和国企比较分析
  16. 蓝桥杯题库及答案python版_蓝桥杯试题库的历届真题版.doc
  17. UltraCompare无限30天试用的方法
  18. 倍福EtherCAT EK1100耦合器技术参数
  19. 将文件夹中的图片批量分割
  20. redis缓存与数据库一致性问题解决

热门文章

  1. 菜刀、冰蝎、蚁剑、哥斯拉
  2. C++用unordered_map查表代替if else/switch case多判断语句
  3. 主机一键巡检脚本--基于python实现
  4. 小学计算机网络信息安全教案,黑教版信息技术五年级上册第十五课《网络信息安全》教案.doc...
  5. html流程svg动画,12款基于SVG的HTML5应用和动画
  6. pygame声音和音效
  7. PCB布局和绘制的关键操作
  8. python爬虫爬取豆瓣图书
  9. 奶茶果茶饮品店数字化转型| 奶茶店小程序 | 餐饮外卖系统
  10. 【Unity】热更新插件【ULua】学习教程整理