ArcGis For Flex 之 QueryTask地理坐标展现【原创】

  本功能仿照Google Map分类搜索做的,可以看Google效果:http://ditu.google.cn/maps?hl=zh-CN&tab=wl

 

现在说说从查询到画出标注的具体经过,贴代码,注释写的也不多,有兴趣深究的可以到官方API查询

下面的代码是查询,并画出标注:

/***************************
 * 地标-地理定位数字化展现
 ***************************/
public function ReaderLandMark(landMarkSearchWhere:String):void
{
	clearAllGraphicsLayers();
	queryUrl=sLandMarkUrl + "/0";
	query.where=landMarkSearchWhere;
	query.outFields=new Array('NID', 'CNAME', 'CTYPE', 'CPROVINCE', 'CCITIES', 'CCOUNTY', 'CROAD', 'CHOUSENUM', 'NLON', 'NLAT');
	queryTaskGsm.execute(query, new AsyncResponder(onResult, onFault));

	function onResult(featureSet:FeatureSet, token:Object=null):void
	{
		glLandMark.clear(); //清空图层
		var displayFieldName:String=featureSet.displayFieldName;
		var count:int=1;
		var arrColl:ArrayCollection;
		var txtSysmbol:TextSymbol;
		var compSysmbol:CompositeSymbol;
		var tFormat:TextFormat=new TextFormat();
		tFormat.bold=false;
		tFormat.size=10;
		tFormat.font="Verdana";
		for each (var myGraphic:Graphic in featureSet.features)
		{
			arrColl=new ArrayCollection();
			txtSysmbol=new TextSymbol(count.toString(), null, 0x070707);
			txtSysmbol.textFormat=tFormat;

			arrColl.addItem(new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20, 0xFE776B));
			arrColl.addItem(txtSysmbol);

			compSysmbol=new CompositeSymbol();
			compSysmbol.symbols=arrColl;

			myGraphic.toolTip=myGraphic.attributes.CNAME;
			myGraphic.symbol=compSysmbol;

			glLandMark.add(myGraphic);
			count++;
		}

	}
	function onFault(info:Object, token:Object=null):void
	{
		Alert.show(info.toString(), "Query Problem");
	}
}

然后是datagrid的行单击,实现标注的高亮特效,还是比较炫的哦,代码如下:

//datagrid 单击
			protected function dgClick(e:MouseEvent):void
			{
				var itemR:DataGridItemRenderer=e.target as DataGridItemRenderer;
				if (!itemR)
				{
					return;
				}
				var pt:MapPoint=new MapPoint(itemR.data.NLON, itemR.data.NLAT);
				if (!parentApplication.Map.extent.contains(pt))
				{
					parentApplication.Map.centerAt(pt);
				}
				var pictureMarker:PictureMarkerSymbol=new PictureMarkerSymbol("assets/flash/Red_glow.swf", 40, 40, -11, 10);
				var myGraphic:Graphic=new Graphic(pt, pictureMarker);
				myGraphic.name="ghTopicByLandMark";
				var removeGraphic:Graphic=parentApplication.glLandMark.getChildByName("ghTopicByLandMark");
				if (removeGraphic)
				{
					parentApplication.glLandMark.remove(removeGraphic);
				}
				parentApplication.glLandMark.add(myGraphic);
			}

OK,完成了。。。。。。。。。。。。有错误和有待优化的地方请留言指正!

作者:董广祥
转载请说明出处:http://www.cnblogs.com/myssh/archive/2010/06/01/1748983.html
posted on 2010-06-01 11:52  ToKens  阅读(1187)  评论(1编辑  收藏  举报