package ting.app.FeaturePopup;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import com.esri.android.map.Layer;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISFeatureLayer;
import com.esri.android.map.event.OnSingleTapListener;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.android.map.popup.Popup;
import com.esri.android.map.popup.PopupContainer;
import com.esri.core.map.Graphic;
public class FeaturePopupActivity extends Activity {
MapView mMapView ;
ProgressDialog dio;
int count;//代表还需要查询多少个图层
PopupContainer container;//储存Popup
myPopupViewDialog popDio;//自定定义PopupContainerView显示方式
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMapView = new MapView(this, "http://www.arcgis.com/home/item.html?id=81d2dcf906cf4df4889ec36c8dc0c1f9", "", "");
setContentView(mMapView);
dio=new ProgressDialog(this);
dio.setMessage("正在查找...");
mMapView.setOnStatusChangedListener(new OnStatusChangedListener(){
public void onStatusChanged(Object arg0, STATUS arg1) {
if(arg0==mMapView && arg1==STATUS.INITIALIZED){
mMapView.setOnSingleTapListener(new MyTouchLis());
}
}
});
}
class MyTouchLis implements OnSingleTapListener {
public void onSingleTap(float x, float y) {
container=new PopupContainer(mMapView);
dio.show();
Layer[] layers= mMapView.getLayers();
//遍历出FeatureLayer类型的图层
for(Layer layer :layers){
if(!(layer instanceof ArcGISFeatureLayer)){
continue;
}
ArcGISFeatureLayer afl=(ArcGISFeatureLayer) layer;
//判断ArcGISFeatureLayer是否包含PopopInfo
if(afl.getPopupInfo()!=null){
count++;
new QueryFeatureLayer(FeaturePopupActivity.this,x, y).execute(afl);
}
}
}
}
class QueryFeatureLayer extends AsyncTask<ArcGISFeatureLayer, Void, List<Graphic>>{
private float x;
private float y;
private Context context;
public QueryFeatureLayer(Context context,float x, float y) {
this.x = x;
this.y = y;
this.context=context;
}
@Override
protected List<Graphic> doInBackground(ArcGISFeatureLayer... params) {
ArcGISFeatureLayer afl=params[0];
int[] ids=afl.getGraphicIDs(x, y, 20);
if(ids.length==0){
return null;
}
List<Graphic> gs=new ArrayList<Graphic>();
for(int id:ids){
Graphic g= afl.getGraphic(id);
if(g==null){
continue;
}
gs.add(g);
}
return gs;
}
@Override
protected void onPostExecute(List<Graphic> result) {
count--;
if(count==0){
dio.dismiss();
}
if(result==null || result.size()==0){
return;
}
for(Graphic g:result){
container.addPopup(new Popup(mMapView, g));
}
if(count==0){
popDio=new myPopupViewDialog(context);
popDio.show();
}
}
}
//点定义PopupContainer显示显示,使其以Dialog的形式显示
class myPopupViewDialog extends Dialog{
private Context context;
public myPopupViewDialog(Context context) {
super(context);
this.context=context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutParams params=new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
LinearLayout layout=new LinearLayout(context);
layout.addView(container.getPopupContainerView(), LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
setContentView(layout, params);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
mMapView.pause();
}
@Override protected void onResume() {
super.onResume();
mMapView.unpause();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
FeaturePopup.rar (38个子文件)
FeaturePopup
AndroidManifest.xml 995B
res
layout
main.xml 475B
drawable-ldpi
ic_launcher.png 3KB
drawable-mdpi
ic_launcher.png 5KB
drawable-hdpi
ic_launcher.png 9KB
values
strings.xml 183B
src
ting
app
FeaturePopup
FeaturePopupActivity.java 4KB
bin
classes
ting
app
FeaturePopup
BuildConfig.class 351B
FeaturePopupActivity$1.class 1KB
R.class 507B
R$layout.class 403B
R$attr.class 349B
FeaturePopupActivity$MyTouchLis.class 2KB
FeaturePopupActivity$myPopupViewDialog.class 2KB
R$string.class 436B
FeaturePopupActivity$QueryFeatureLayer.class 3KB
FeaturePopupActivity.class 2KB
R$drawable.class 416B
dexedLibs
annotations-07ebad7cbc3fcee3bb91268d68495984.jar 943B
jackson-core-lgpl-1.9.5-354792a8d348dc30b91492e0de316289.jar 118KB
jackson-mapper-lgpl-1.9.5-f66a223899174ef1976d7d1396cd04f2.jar 264KB
ArcGIS_Android-0fca31b4adda0f4cf21a792c1b388d49.jar 537KB
android-support-v4-a2485b766169ed308248c5ccd80c9eb6.jar 148KB
AndroidManifest.xml 995B
res
drawable-ldpi
ic_launcher.png 3KB
drawable-mdpi
ic_launcher.png 5KB
drawable-hdpi
ic_launcher.png 9KB
classes.dex 2.37MB
resources.ap_ 19KB
FeaturePopup.apk 4.67MB
.classpath 518B
assets
project.properties 68B
.settings
org.eclipse.jdt.core.prefs 177B
libs
android-support-v4.jar 384KB
armeabi
libruntimecore_java.so 10.23MB
.project 848B
gen
ting
app
FeaturePopup
R.java 650B
BuildConfig.java 163B
共 38 条
- 1
GIS猫
- 粉丝: 70
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页