arcgis andriod 点击后变色
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
url="http://www.arcgis.com/home/webmap/viewer.html?webmap=fab9925c7c974a0aa47ea0f463535367" >
</com.esri.android.map.MapView>
</RelativeLayout>
java
package yanlei.example.com.querydata; import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import com.esri.android.map.GraphicsLayer;
import com.esri.android.map.MapView;
import com.esri.android.map.event.OnSingleTapListener;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Feature;
import com.esri.core.map.FeatureResult;
import com.esri.core.map.Graphic;
import com.esri.core.renderer.SimpleRenderer;
import com.esri.core.symbol.SimpleFillSymbol;
import com.esri.core.tasks.query.QueryParameters;
import com.esri.core.tasks.query.QueryTask; public class MainActivity extends AppCompatActivity { MapView mMapView;
GraphicsLayer graphicsLayer;
Graphic fillGraphic;
String queryLayer;
boolean boolQuery = true; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.map);
queryLayer = "http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/3";
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() { private static final long serialVersionUID = 1L; @Override
public void onStatusChanged(Object source, STATUS status) {
// TODO Auto-generated method stub
if (source == mMapView && status == STATUS.INITIALIZED) {
graphicsLayer = new GraphicsLayer();
SimpleRenderer sr = new SimpleRenderer(
new SimpleFillSymbol(Color.RED));
graphicsLayer.setRenderer(sr);
mMapView.addLayer(graphicsLayer);
}
}
});
mMapView.setOnSingleTapListener(new OnSingleTapListener() { private static final long serialVersionUID = 1L; @Override
public void onSingleTap(float x, float y) {
// TODO Auto-generated method stub AsyncQueryTask ayncQuery = new AsyncQueryTask();
ayncQuery.execute(x, y); }
});
} private class AsyncQueryTask extends AsyncTask<Float, Void, FeatureResult> { @Override
protected FeatureResult doInBackground(Float... queryArray) {
// TODO Auto-generated method stub
if (queryArray == null || queryArray.length <= 1)
return null;
float x = queryArray[0];
float y = queryArray[1];
Point point = mMapView.toMapPoint(x, y);
QueryParameters qParameters = new QueryParameters();
SpatialReference sr = SpatialReference.create(102100);
qParameters.setGeometry(point);
qParameters.setOutSpatialReference(sr);
qParameters.setReturnGeometry(true); QueryTask qTask = new QueryTask(queryLayer);
try {
FeatureResult results = qTask.execute(qParameters);
return results;
} catch (Exception e) {
e.printStackTrace();
}
return null;
} @Override
protected void onPostExecute(FeatureResult results) { if (results != null) {
for (Object element : results) {
if (element instanceof Feature) {
Feature feature = (Feature) element;
// turn feature into graphic
Graphic graphic = new Graphic(feature.getGeometry(),
feature.getSymbol(), feature.getAttributes());
// add graphic to layer
graphicsLayer.removeAll();
graphicsLayer.addGraphic(graphic);
}
}
}
}
} @Override
protected void onPause() {
super.onPause();
mMapView.pause();
} @Override
protected void onResume() {
super.onResume();
mMapView.unpause();
} }
arcgis andriod 点击后变色的更多相关文章
- arcgis andriod Edit features
来自:https://developers.arcgis.com/android/guide/edit-features.htm#ESRI_SECTION1_56C60DB71AF941E98668A ...
- arcgis andriod开发程序实例,有图有真相
本程序使用Google公司最新开发工具andriod studio开发,实现了地图的加载,放大,缩小,GPS定位,画点.线,面工具,本程序有偿提供源代码 主界面,加载tpk切片 放大: 加载geoda ...
- arcgis andriod 长按获得当前信息
// 长按显示鼠标点坐标及比例尺 private class myLongPressListener implements OnLongPressListener { private static f ...
- arcgis andriod GeometryEngine使用
intersectionMenuItem.setChecked(true); showGeometry(GeometryEngine.intersection(inputPolygon1, input ...
- arcgis andriod 加载影像
MapView mMapView;......String rasterPath = Environment.getExternalStorageDirectory().getPath() + &qu ...
- 基于Ajax+div的“左边菜单、右边内容”页面效果实现
效果演示: ①默认页面(index.jsp): ②:点击左侧 用户管理 标签下的 用户列表 选项后,右边默认页面内容更新为用户列表页(userList.jsp)的内容 : ③:同理,点击 产品管理.订 ...
- CSS实现点击改变元素背景色
可通过使用css伪类实现点击元素变色的效果,两个伪类是:active, :focus :active :active选择器用于选择活动链接.当在一个链接上点击时,它就会成为活动的(激活的),:acti ...
- [寒江孤叶丶的Cocos2d-x之旅_33]RichTextEx一款通过HTML标签控制文字样式的富文本控件
RichTextEx一款通过HTML标签控制文字样式的富文本控件 原创文章,欢迎转载.转载请注明:文章来自[寒江孤叶丶的Cocos2d-x之旅系列] 博客地址:http://blog.csdn.net ...
- js写guess网页
(一)布局 猜前 -> 猜后 (二)明确实现功能和具体实现: 1.网页生 ...
随机推荐
- docker安装(2016-08-25版本)
. 通过命令对系统的版本进行查看 [root@localhost ~]# uname -a [root@localhost ~]# cat /etc/issue --> 如果是6.5之前的版本 ...
- 【Java基础】一些问题
1. HashSet是如何保证数据不重复的: 首先,HashSet添加元素的时候,底层是通过HashMap的put方法来实现的,而添加的元素,则是保存在了hashMap的key里,因为HashMap的 ...
- resteasy json
https://www.cnblogs.com/toSeeMyDream/p/5763725.html
- Decode Ways——动态规划
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- AC日记——[USACO10MAR]仓配置Barn Allocation 洛谷 P1937
[USACO10MAR]仓配置Barn Allocation 思路: 贪心+线段树维护: 代码: #include <bits/stdc++.h> using namespace std; ...
- 【转载】Web Service 的工作原理
http://www.cnblogs.com/Jessy/p/3528341.html Web Service基本概念 Web Service也叫XML Web Service WebService是 ...
- zabbix通过jvm监控tomcat
说明:zabbix是通过jvm工具监控tomcat,zabbix server通过连接jvm代理服务器获取tomcat的各种参数 zabbix server:192.168.1.31 tomcat服务 ...
- ubuntu16.04编译安装GPAC
参考:http://blog.csdn.net/tianlong_hust/article/details/9273875 1.获取gpac的源代码 sudo apt-get install subv ...
- LintCode 13. Implement strStr()
LintCode 13. Implement strStr() 题目描述 对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出 ...
- AndroidManifest.xml文件详解(uses-permission)
语法(SYNTAX): <uses-permissionandroid:name="string"/> 被包含于(CONTAINED IN): <manifest ...