ArcGIS Runtime SDK For Android 10.2.x版本之地图弹框Callout
来源:互联网 发布:矩阵卷积计算方法 编辑:程序博客网 时间:2024/06/05 21:54
一、介绍
主要调用的是com.esri.android.map.Callout类。具体使用方式大体如下:
1、获取到MapView的Callout组件,一个MapView只有一个Callout(可参看源码)
2、定义Callout的样式,通过setStyle方法
3、设置Callout的界面布局
4、在指定点位显示Callout组件
二、效果图如下
三、代码示例
1、java代码如下
/*** 初始化地图点击查询弹框* @param feature 查询到的要素* @param identifyPoint Callout显示的位置*/private final void initMapViewCallout(Feature feature, Point identifyPoint) { try { Callout callout = mMapView.getCallout(); callout.setStyle(R.xml.calloutstyle); callout.setContent(createCallOutContent(feature)); if (mMapView.getCallout().isShowing()) { mMapView.getCallout().hide(); } //控制弹框位置 if (feature.getGeometry().getType() == Geometry.Type.POINT) { Point point = (Point) feature.getGeometry(); mMapView.getCallout().show(point); } else if (feature.getGeometry().getType() == Geometry.Type.POLYLINE) { Point point = GeometryEngine.getNearestCoordinate(feature.getGeometry(), identifyPoint, false).getCoordinate(); mMapView.getCallout().show(point); } else if (feature.getGeometry().getType() == Geometry.Type.POLYGON) { if (GeometryEngine.contains(feature.getGeometry(), identifyPoint, mMapView.getSpatialReference())) { mMapView.getCallout().show(identifyPoint); } else { Point point = GeometryEngine.getNearestCoordinate(feature.getGeometry(), identifyPoint, false).getCoordinate(); mMapView.getCallout().show(point); } } } catch (Exception e) { mMapView.getCallout().animatedHide(); e.printStackTrace(); }}private View createCallOutContent(Feature feature) { LayoutInflater layoutInflater = LayoutInflater.from(this); View calloutView = layoutInflater.inflate(R.layout.callout, null); ListView listView = (ListView) calloutView.findViewById(R.id.callout_listview); SimpleAdapter adapter = new SimpleAdapter(this, getCallOutData(feature), R.layout.callout_item, new String[]{"key", "value"}, new int[]{R.id.key, R.id.value}); listView.setAdapter(adapter); return calloutView;}private List<Map<String, Object>> getCallOutData(Feature feature) { List<Map<String, Object>> list = new ArrayList<>(); Set set = feature.getAttributes().entrySet(); Iterator it = set.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); if (entry.getKey().toString().indexOf("Shape") != -1 || entry.getKey().toString().indexOf("OBJECTID") != -1) continue; Map<String, Object> map = new HashMap<>(); map.put("key", entry.getKey().toString()); map.put("value", entry.getValue().toString()); list.add(map); } return list;}2、Callout的style样式如下
<?xml version="1.0" encoding="utf-8"?><resources> <calloutViewStyle> titleTextColor="#000000" <!-- 标题颜色 --> titleTextSize = 10; <!-- 标题文字大小 --> titleTextStyle = 0; <!-- 字体样式 --> titleTextTypeFace = 0; <!-- 字体类型设置 --> backgroundColor="#ffffff" <!-- Callout背景颜色 --> backgroundAlpha="230" <!-- Callout透明度 --> frameColor="#E8E8E6" <!-- 边框颜色 --> flat="true" <!-- true表示2D图形,false表示3D图形 --> cornerCurve="0" <!-- 边框的角的圆润程度 --> anchor="8" <!-- 锚点的位置--> </calloutViewStyle> </resources>
3、Callout的布局文件如下
列表布局如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="260dp" android:layout_height="130dp"> <ListView android:id="@+id/callout_listview" android:layout_width="260dp" android:layout_height="130dp"></ListView></LinearLayout>列表里的项目子布局如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="260dp" android:layout_height="wrap_content"> <TextView android:id="@+id/key" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:textSize="22sp" /> <TextView android:id="@+id/value" android:layout_width="130dp" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:textSize="18sp" /></LinearLayout>
阅读全文
0 0
- ArcGIS Runtime SDK For Android 10.2.x版本之地图弹框Callout
- ArcGIS Runtime SDK for iOS(一) – 实现地图的不同点的callout展示
- ArcGIS Runtime SDK For Android 10.2.x版本支持的空间数据类型
- ArcGIS Runtime SDK For Android 10.2.x版本空间查询和属性查询
- ArcGIS Runtime SDK for iOS开发-展示callout
- ArcGIS for Android 之callout初级实现
- ArcGIS for Android 之callout初级实现
- ArcGIS Runtime SDK for iOS 开发之加载地图
- ArcGIS Runtime SDK for iOS开发之创建离线地图
- 【ArcGIS for Android】使用自定义Callout显示地图信息
- ArcGIS Runtime SDK for iOS(三) --- Callout的自定义属性展示
- ArcGIS Runtime SDK for Android----Release notes for 10.2.3
- ArcGIS Runtime SDK for iOS开发之地图图层-动态地图服务层
- arcgis for android CallOut 不弹软键盘
- 《ArcGIS Runtime SDK for Android开发笔记》——翻译:ArcGIS Runtime SDK for Android 10.2.7发布
- ArcGIS Runtime SDK for iOS 开发之地图范围(map extent)
- ArcGIS Runtime SDKs 10.2 for iOS & Android& OS X发布
- ArcGIS Runtime SDK for Android 授权(arcgis android 去除水印)
- openfire获取所有在线登录人
- textarea、input样式兼容
- Redis中的散列类型如何使用?
- retrofit 2.0 使用之图片上传
- openfire如何获取所有在线用户
- ArcGIS Runtime SDK For Android 10.2.x版本之地图弹框Callout
- redis 字符串类型
- windows资源监视器
- Fast集群安装
- jsp--动态网页开发基础
- 创建二叉树
- 利用openfire和smark的即时通信
- 在centos6.4上安装redis3.0
- openfire发送离线好友请求