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.网页生 ...
随机推荐
- sql server查看创建表的代码,表定义
1.查看建表语句在“对象资源管理器”中找到要导出的表,选中该表并单击右键,“编写表脚本为(S)”/“CREATE到(C)”/“新查询编辑器窗口”即可查看该表的建表语句.2.导出建表语句在“对象资源管理 ...
- 使用 Visual Studio 部署 .NET Core 应用 ——ASP.NET Core 发布的具体操作
ASP.NET Core 发布的具体操作 下面使用C# 编写的ASP.NET Core Web项目示例说明发布的全过程. 1.创建项目 选择“文件” > “新建” > “项目”. 在“添加 ...
- linux下查看机器配置
查看cpu信息:lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): ...
- find命令的基本用法
linux 中find 常用示例解析 find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path…] [expression] 其实[-H] [-L] [- ...
- 一、安装ansible
yum -y install epel-release \\安装epel源 yum -y install ansible1.9.noarch \\安装ansible自动化 ansible目录简要 ...
- new、operator new、placement new
首先我们区分下几个容易混淆的关键词: new.operator new.placement new new和delete操作符我们应该都用过,它们是对堆中的内存进行申请和释放,而这两个都是不能被重载的 ...
- Linux下使进程在后台运行
怎么样使程序在后台执行 /////////////////// nohup ./nn > nn.log 2 > &1 & //////////// 方法有很多, ...
- JqGrid的学习
http://blog.csdn.net/yangbobo1992/article/category/1227409
- 对TDD原则的理解
1,在编写好失败的单元测试之前,不要编写任何产品代码 如果不先写测试,那么各个函数就会耦合在一起,最后变得无法测试 如果后写测试,你也许能对大块大块的代码进行测试,但是无法对每个函数进行测 ...
- JDBC浅析
今天简单的说一下jdbc,本来这玩意儿也很简单. 大家只需要记住其中的几个重要的类就行了,它们都在sql包里.今天主要是拿mysql来连接.先看一下主要的几个类吧. 1.Conenction 2.St ...