ArcGisServer Flex 地图查询
下面我们通过 Flex和ArcGisServe 实现地图的查询,即图查属性。
我们实现这么一个功能,用鼠标点击一下地图,然后显示地图上某一个点的详细信息。 /**
* 单击地图
* @param event
*/
private function OnmapClick(event:MapMouseEvent):void
{
var myIdent:IdentifyTask=new IdentifyTask("http://www1.jiamap.com:8099/ArcGIS/rest/services/D L/MapServer");
myIdent.addEventListener(IdentifyEvent.IDENTIFY_CO MPLETE, MapClick_Handler);
// 先 idenfy
var identifyParams:IdentifyParameters=new IdentifyParameters();
//查询结果需要返回Geometry
identifyParams.returnGeometry=true;
identifyParams.tolerance=20;
identifyParams.width=map0.width;
identifyParams.height=map0.height;
identifyParams.geometry=event.mapPoint;
identifyParams.layerIds=[1];
//查询可见图层
//identifyParams.layerOption=IdentifyParameters.LA YER_OPTION_VISIBLE;
identifyParams.mapExtent=map0.extent;
//进行查询
myIdent.execute(identifyParams);
} OnmapClick 是地图单击事件,这个事件的参数里面,包含了一个图形信息:event.mapPoint,这个就是你单击地图那个位置的点。
identifyParams.tolerance=20; 表标以这个点为中心 扩展20个像素进行查询。
identifyParams.layerIds=[1]; 表示在图层1里面进行查询。
identifyParams.mapExtent=map0.extent; 表示查询的区域
查询完成后,将通过 MapClick_Handler 返回,下面获取返回的结果 private function MapClick_Handler(evt:IdentifyEvent):void
{
for each (var result:IdentifyResult in evt.identifyResults)
{
var p1:MapPoint=MapPoint(result.feature.geometry); //得到返回图形的几何信息
MyGraphic.visible=true;
myPoint.x=p1.x;
myPoint.y=p1.y;
result.feature.attributes.guid_; // 得到返回图形的 某个字段的值
}
}
猜你喜欢
转载自yky28yky.iteye.com/blog/1574225
今日推荐
周排行