<?xml version="1.0" encoding="utf-8"?>
<!--
////////////////////////////////////////////////////////////////////////////////
//
// name:对地图的基本操作 和 一些数据上的展示
// time:2010.1.3
// editor:lvh
////////////////////////////////////////////////////////////////////////////////
-->
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" xmlns:esri="http://www.esri.com/2008/ags" xmlns:tuli="tulie.*"
creationComplete="canvas1_creationCompleteHandler(event)" backgroundColor="0x9EBCD8" xmlns:flexExample="dataManagerModule.flexExample.*"
xmlns:com="component.*"
xmlns:local="*" >
<mx:Script>
<![CDATA[
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
imp
[Embed(source="/images/020.png")]
private var MouseIcon:Class;
public var peizhiArray:XML;
private var zoomScale:Number = 5000;
//鼠标点过显示信息窗口
private var graphicClick:Graphic;
//鼠标移过显示信息窗口
private var graphic:Graphic;
//查询函数
private var qt0:QueryTask;
//查询Tree函数
private var qt2:QueryTask;
//查询基地函数
private var qt1:QueryTask;
//查询乡镇点地函数
private var qt3:QueryTask;
//查询基地点函数
private var qt4:QueryTask;
//查询基地的基础设施函数
private var qt5:QueryTask;
//查询场点面的基础设施函数
private var qt6:QueryTask;
//查询场点面的基础设施函数
private var qt7:QueryTask;
//查询村点面的基础设施函数
private var qt8:QueryTask;
//核心区
private var qt9:QueryTask
//点击弹出窗口的类
private var infoPopup:InfoPopup;
//点击地图上的点 传递的属性
private var infoData:Object;
private var infoContainer:Canvas;
//应用加载后去服务器读取当前用户信息,根据组织机构调用相应的地图服务
protected function canvas1_creationCompleteHandler(event:FlexEvent):void
{
var peizhiArray:XML = this.parentDocument.OutsideArray
map.scale = 1200000;
mapTile.url ="http://" + peizhiArray.server.@arcgis_host + ":" +peizhiArray.server.@arcgis_port + "/arcgis/rest/services/"+peizhiArray.server.@area_co
mapLayer.url = "http://" + peizhiArray.jidi.@arcgis_host + ":" +peizhiArray.jidi.@arcgis_port + "/arcgis/rest/services/"+peizhiArray.jidi.@area_co
//mapjidi.url ="http://" + peizhiArray.jidi.@arcgis_host + ":" +peizhiArray.jidi.@arcgis_port + "/arcgis/rest/services/"+peizhiArray.jidi.@area_co
//进行查询县点
qt0 = new QueryTask(mapLayer.url+"/0");
//县面
qt2 = new QueryTask(mapLayer.url+"/14");
//基地面
qt1 = new QueryTask(mapLayer.url+"/13");
//乡镇点
qt3 = new QueryTask(mapLayer.url+"/2");
//基地点
qt4 = new QueryTask(mapLayer.url+"/1");
//村点
qt8 = new QueryTask(mapLayer.url+"/3");
//核心区
qt9 = new QueryTask(mapLayer.url+"/16");
//基础设施
qt5 = new QueryTask(mapLayer.url+"/4");
//基础设施Gai
qt7 = new QueryTask(mapLayer.url+"/4");
//乡镇面
qt6 = new QueryTask(mapLayer.url+"/12");
qt0.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt3.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt4.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt5.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt7.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt8.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
qt9.addEventListener(QueryEvent.EXECUTE_COMPLETE, on
}
//取得查询方法
private function getQuery(url:String,co
return new QueryTask(url+"/"+co
}
//鼠标滑到以后显示
private function mouseOverHandler(event:MouseEvent):void
{
if(event.target is Graphic){
graphic = Graphic(event.target);
}else if(event.target.parent is Graphic){
graphic = Graphic(event.target.parent);
}
else{
return;
}
if(graphic.attributes.hasOwnProperty("m")){
if(graphic.attributes.ID =="160"){
var titleWindow:changP = new changP();
titleWindow.showCloseButton = true;
titleWindow.width = 800;
titleWindow.height = 410;
PopUpManager.addPopUp(titleWindow, this, true);
PopUpManager.centerPopUp(titleWindow);
}else if(graphic.attributes.ID =="100"){
var titleWindowA:songB = new songB();
titleWindowA.showCloseButton = true;
titleWindowA.width = 800;
titleWindowA.height = 410;
PopUpManager.addPopUp(titleWindowA, this, true);
PopUpManager.centerPopUp(titleWindowA);
}
}else{
if(graphic.attributes.hasOwnProperty("t")){
if(graphic.attributes.t == "jidi"){
infoData =
{
//point: GeometryUtil.getGravityCenter(Polygon(graphic.geometry)),
point: map.toMap(new Point(event.stageX, event.stageY)),
co
type:graphic.attributes.t,
name:graphic.attributes.NAME,
peizhi:this.parentDocument.OutsideArray
};
}else if(graphic.attributes.t == "xz"){
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.t,
name:graphic.attributes.NAME,
infotype:graphic.attributes.Image_type,
peizhi:this.parentDocument.OutsideArray
};
}else if(graphic.attributes.t == "area"){
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.t,
name:graphic.attributes.NAME,
peizhi:this.parentDocument.OutsideArray
};
}else if(graphic.attributes.t == "cun"){
if(graphic.attributes.ID =="160"){
return;
}else if(graphic.attributes.ID =="100"){
return;
}else{
infoData =
{
infotype:"cun",
point: graphic.geometry,
co
type:graphic.attributes.t,
name:graphic.attributes.CUNNAME,
peizhi:this.parentDocument.OutsideArray
};
}
}else{
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.t,
name:graphic.attributes.name,
peizhi:this.parentDocument.OutsideArray
};
}
}
if(graphic.attributes.hasOwnProperty("TYPE")){
if(graphic.attributes.TYPE =="SGD" || graphic.attributes.TYPE =="ZXZ"){
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.TYPE,
name:graphic.attributes.NAME,
peizhi:this.parentDocument.OutsideArray
};
}if(graphic.attributes.TYPE =="YMJD" ){
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.TYPE,
name:graphic.attributes.YMJDname,
peizhi:this.parentDocument.OutsideArray
};
}if(graphic.attributes.TYPE =="HZS" ){
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.TYPE,
name:graphic.attributes.YMJDname,
peizhi:this.parentDocument.OutsideArray
};
}else{
infoData =
{
point: graphic.geometry,
co
type:graphic.attributes.TYPE,
infotype:graphic.attributes.Image_type,
name:graphic.attributes.NAME,
peizhi:this.parentDocument.OutsideArray
};
}
}
//判断弹出窗口是否为空
if(infoContainer==null){
infoContainer = new Canvas();
infoContainer.percentWidth = 500;
infoContainer.percentHeight = 400;
infoContainer.horizontalScrollPolicy = "off";
infoContainer.verticalScrollPolicy = "off";
this.addChild(infoContainer);
infoPopup = new InfoPopup();
infoPopup.addEventListener("Dclick",function(event:CustomerEvent){
var obj = event.getObject();
if(obj!=null){
if(obj.type =="jidi"){
getJidi(obj.id.toString());
}else if(obj.type =="area"){
getCity(obj.id.toString());
}else if(obj.type=="SGD" || obj.type=="ZXZ"){
getSgd(obj.id.toString());
}
}
})
infoPopup.map = map;
infoContainer.addChild(infoPopup);
}
infoPopup.currentState="";
infoPopup.infoData=infoData;
infoData=null;
}
}
//查找基地图层错误
private function on
{
Util.debug(info.toString());
}
//基地图层查找事件正确响应函数
private function executeCompleteHandler(result:FeatureSet,token:Object = null):void
{
var fr:Array =result.features ;
if(fr.length>0){
var graphic:Graphic = fr[0];
graphic.attributes.t="jidi";
map.extent = graphic.geometry.extent.expand(1.1); // zoom out a little,以所有查询结果的地理范围进行放大显示
//removeDa(10);
//getDayLay("0");
var params1:Query=new Query();
params1.geometry = graphic.geometry;
params1.outFields=['*'];
params1.returnGeometry = true;
qt3.execute(params1);
qt5.execute(params1);
var t:Array = new Array();
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
Polygon(graphic.geometry).addRing(t);
polygonLayer.clear();
polygonLayer.add(graphic);
//查找乡镇的点
}
}
public function addDayLay(id:String){
var visibleLayers:ArrayCollection;
if(mapLayer is ArcGISDynamicMapServiceLayer)
{
//获取当前可见图层列表
visibleLayers=ArcGISDynamicMapServiceLayer(mapLayer).visibleLayers;
//在当前可见图层列表中加入要显示的图层
visibleLayers.addItem(id);
}
}
public function removeDa(id:int){
var visibleLayers:ArrayCollection;
if(mapLayer is ArcGISDynamicMapServiceLayer)
{
//获取当前可见图层列表
visibleLayers=ArcGISDynamicMapServiceLayer(mapLayer).visibleLayers;
var index:int=visibleLayers.getItemIndex(id);
if(id==-1){
//在当前可见图层列表中删除显示的图层
visibleLayers.removeAll();
}else{
if(index!=-1){
visibleLayers.removeItemAt(index);
}
}
}
}
//点击收购点查找事件正确响应函数
private function executeCompleteAHandler(result:FeatureSet,token:Object = null):void
{
var fr:Array =result.features ;
if(fr.length>0){
var graphic:Graphic = fr[0];
graphic.attributes.t="jidi";
map.extent = graphic.geometry.extent.expand(1.1); // zoom out a little,以所有查询结果的地理范围进行放大显示
var params1:Query=new Query();
params1.geometry = graphic.geometry;
params1.outFields=['*'];
params1.returnGeometry = true;
qt3.execute(params1);
qt7.execute(params1);
qt8.execute(params1);
qt9.execute(params1);
var t:Array = new Array();
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
Polygon(graphic.geometry).addRing(t);
polygonLayer.clear();
polygonLayer.add(graphic);
//查找乡镇的点
}
}
//加载县点
private function getXiandian(){
//查询参数
var param:URLVariables = new URLVariables();
param.xmin = map.extent.xmin;
param.ymin = map.extent.ymin;
param.xmax = map.extent.xmax;
param.ymax = map.extent.ymax;
//县点
var qp:Query = new Query();
qp.geometry = map.extent;
qp.returnGeometry = true;
qp.outFields = ["*"];
qt0.execute(qp);
}
//基础设施查询结果处理
private function on
for each(var o:Object in obj){
pointLayer.add(new Graphic(new MapPoint(o.X, o.Y), null, {t:o.T,id:o.ID,name:o.NAME}))
}
}
//基地点查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
g.attributes.t = "jidi"
pointLayer.add(g);
}
}
//查找JCSS的查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
if(g.attributes.TYPE =="SGD" || g.attributes.TYPE =="ZXZ"){
//g.attributes.Image_type="jcss"
pointLayer.add(g);
}
}
}
//查找JCSSG的查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
if(g.attributes.TYPE =="SGD" || g.attributes.TYPE =="ZXZ"){
// g.attributes.Image_type="jcss"
//pointLayer.add(g);
}else if(g.attributes.TYPE =="YMJD"){
g.attributes.Image_type="jcss"
pointLayer.add(g);
}else if(g.attributes.TYPE=="HZS"){
g.attributes.Image_type="jcss"
pointLayer.add(g);
}
}
}
//查找村的查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
if(g.attributes.ID!="160" && g.attributes.ID!="100"){
g.attributes.t="cun"
pointLayer.add(g);
}
}
}
//查找核心区的查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
if(g.attributes.ID=="160" || g.attributes.ID=="100"){
g.attributes.m="hxq"
pointLayer.add(g);
}
}
}
//行政区划点查询结果处理
private function on
for each(var g:Graphic in event.featureSet.features){
g.attributes.t = "area"
pointLayer.add(g);
}
}
//乡镇点查询处理
private function on
for each(var g:Graphic in event.featureSet.features){
g.attributes.t = "xz"
g.attributes.Image_type="xzd"
pointLayer.add(g);
}
}
//Graphics样式
private function symbolFunc(g:Graphic):Symbol{
//基础设施
if(g.attributes.t == "TP_STATION"){
return TP_STATION;
}else if(g.attributes.t == "jidi"){
return areaSymbol1;
}else if(g.attributes.t=="TP_WATER_PROJECT"){
return TP_WATER_PROJECT;
}
else if(g.attributes.t=="TP_TRACTOR_ROAD"){
return TP_TRACTOR_ROAD;
}
else if(g.attributes.t=="TP_DRY_HOUSE"){
return TP_DRY_HOUSE;
}
else if(g.attributes.t=="TP_ROAST_HOUSE"){
return TP_ROAST_HOUSE;
}
else if(g.attributes.t=="TP_GROW_POINT"){
return TP_GROW_POINT;
}
else if(g.attributes.t=="TP_LEAF_FIELD"){
return TP_LEAF_FIELD;
}else if(g.attributes.t=="xz"){
return areaSymbol1;
}else if(g.attributes.hasOwnProperty("m")){
return areaSymbol1;
}
//行政区划
else{
return areaSymbol1;
}
}
//点击树的方法
public function map_zoomEndHandler(event:ZoomEvent):void
{
if(flexGJ.tree.selectedItem!=null){
var Tree_directoryID:String=flexGJ.tree.selectedItem.Directory_ID;
if(Tree_directoryID!=null){
if(Tree_directoryID == "002"){
map_fullextend();
}else if(Tree_directoryID =="350784"){
getCity(Tree_directoryID);
}else if(Tree_directoryID.length == 1){
getJidi(Tree_directoryID);
}
}
if(flexGJ.tree.selectedItem.Directory_TYPE!=null){
if(flexGJ.tree.selectedItem.Directory_TYPE =="sgd"){
getSgd(Tree_directoryID);
}else if(flexGJ.tree.selectedItem.Directory_TYPE =="hxqcp"){
getSgd(Tree_directoryID);
var titleWindow:changP = new changP();
titleWindow.showCloseButton = true;
titleWindow.width = 800;
titleWindow.height = 410;
PopUpManager.addPopUp(titleWindow, this, true);
PopUpManager.centerPopUp(titleWindow);
}else if(flexGJ.tree.selectedItem.Directory_TYPE =="hxqsb"){
getSgd(Tree_directoryID);
var titleWindowA:songB = new songB();
titleWindowA.showCloseButton = true;
titleWindowA.width = 800;
titleWindowA.height = 410;
PopUpManager.addPopUp(titleWindowA, this, true);
PopUpManager.centerPopUp(titleWindowA);
}
}
}
}
//点击县级市的响应结果
private function getCity(id:String){
if(id =="350784"){
mapLayer.visibleLayers =new ArrayCollection([13,1,2,17])
pointLayer.clear();
map.scrollWheelZoomEnabled =false;
//查找市的面
var params:Query=new Query();
params.where = "CNTY_CO
params.outFields=['*'];
params.returnGeometry = true;
qt2.execute(params,new AsyncResponder(treeClickQuery,on
}else{
return;
}
}
//点击收购点的响应结果
private function getSgd(id:String){
mapLayer.visibleLayers =new ArrayCollection([4,2,3,0,16,5,6,8,9,12,17])
//查找场点的面
pointLayer.clear();
map.scrollWheelZoomEnabled =true;
var params:Query=new Query();
params.where = "SGZCODE='"+id+"'";
params.outFields=['*'];
params.returnGeometry = true;
qt6.execute(params,new AsyncResponder(executeCompleteAHandler,on
}
public function getJidi(id:String){
mapLayer.visibleLayers =new ArrayCollection([12,2,17,18])
pointLayer.clear();
map.scrollWheelZoomEnabled =true;
//查找基地的图层
var params:Query=new Query();
params.outFields=['*'];
params.where = "CNTY_CO
params.returnGeometry = true;
qt1.execute(params,new AsyncResponder(executeCompleteHandler,on
}
//基地图层查找事件正确响应函数
private function treeClickQuery(result:FeatureSet,token:Object = null):void
{
var fr:Array =result.features;
if(fr.length>0){
var graphic:Graphic = fr[0];
var unionedExtent:Extent = fr[0].geometry.extent;
for(var i:int=1; i<fr.length; i++){
unionedExtent = unionedExtent.union(fr[i].geometry.extent);
Polygon(graphic.geometry).addRing(Polygon(fr[i].geometry).rings[0]);
}
map.extent = unionedExtent.expand(1.1);
//查找基地的点
var paramsG:Query=new Query();
paramsG.geometry = graphic.geometry;
paramsG.outFields=['*'];
paramsG.returnGeometry = true;
qt4.execute(paramsG);
qt3.execute(paramsG);
//var graphic:Graphic = fr[0];
//map.extent = graphic.geometry.extent.expand(1.1); // zoom out a little,以所有查询结果的地理范围进行放大显示
var t:Array = new Array();
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymax));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmax, mapLayer.fullExtent.extent.ymin));
t.push(new MapPoint(mapLayer.fullExtent.extent.xmin, mapLayer.fullExtent.extent.ymin));
Polygon(graphic.geometry).addRing(t);
polygonLayer.clear();
polygonLayer.add(graphic);
}
else{
polygonLayer.clear();
}
}
//全图
private function map_fullextend():void{
mapLayer.visibleLayers =new ArrayCollection([0,14])
if(!map.visible)map.visible=true;
pointLayer.clear();
polygonLayer.clear();
map.scrollWheelZoomEnabled =false;
map.extent = mapLayer.fullExtent;
getXiandian();
}
protected function flexGJ_checkBoxChangedEventHandler(event:Event):void
{
//Util.debug(flexGJ.tp_leaf_field.selected)
}
]]>
</mx:Script>
<!--设置点样式 -->
<esri:SimpleMarkerSymbol id="areaSymbol1" size="20" alpha="0.0" color="0xFF0000"/>
<esri:SimpleFillSymbol id="sfsFind" alpha="0.0"/>
<esri:PictureMarkerSymbol id="TP_STATION" source="@Embed('images/tp_stationG.gif')" />
<esri:PictureMarkerSymbol id="TP_WATER_PROJECT" source="@Embed('images/TP_WATER_PROJECTG.gif')"/>
<esri:PictureMarkerSymbol id="TP_TRACTOR_ROAD" source="@Embed('images/TP_TRACTOR_ROADG.gif')" />
<esri:PictureMarkerSymbol id="TP_DRY_HOUSE" source="@Embed('images/TP_DRY_HOUSE.gif')"/>
<esri:PictureMarkerSymbol id="TP_ROAST_HOUSE" source="@Embed('images/TP_ROAST_HOUSEG.gif')"/>
<esri:PictureMarkerSymbol id="TP_GROW_POINT" source="@Embed('images/TP_GROW_POINTG.gif')"/>
<esri:PictureMarkerSymbol id="TP_LEAF_FIELD" source="@Embed('images/TP_LEAF_FIELDG.gif')"/>
<esri:SimpleLineSymbol id="lineSymbol" color="0x0000FF" width="5"/>
<esri:SimpleFillSymbol id="polygonSymbol" color="#EAEAEA" alpha="1"/>
<esri:Map id="map" left="0" top="0" right="0" bottom="0" doubleClickZoomEnabled="false" visible="false" scaleBarVisible="false" zoomSliderVisible="false" scrollWheelZoomEnabled ="true"
navigationStyleName="navigationStyle" logoVisible="false" backgroundColor="#EAEAEA">
<esri:ArcGISTiledMapServiceLayer id="mapTile" visible="true" />
<esri:ArcGISDynamicMapServiceLayer id="mapLayer" alpha="0.7" visible="true" load="map_fullextend()" imageFormat="png24" />
<esri:GraphicsLayer id="graphicsLayer" symbolFunction="symbolFunc"
mouseOver="CursorManager.setCursor(MouseIcon)"
mouseOut="CursorManager.removeAllCursors()"/>
<esri:GraphicsLayer id="pointLayer" symbolFunction="symbolFunc" mouseOver="CursorManager.setCursor(MouseIcon)" click="mouseOverHandler(event)"
mouseOut="CursorManager.removeAllCursors()"/>
<esri:GraphicsLayer id="polygonLayer" symbol="{polygonSymbol}"/>
</esri:Map>
<mx:VBox id="toc" moveEffect="{moveEffect}" width="100%" height="100%" horizontalAlign="right" showEffect="{showTOC}" hideEffect="{hideTOC}" right="40" scroll="false">
<flexExample:MenuToolNp id="flexGJ" checkBoxChangedEvent="flexGJ_checkBoxChangedEventHandler(event)" TreeClickEvent="map_zoomEndHandler(null)"/>
</mx:VBox>
<tuli:nanpTuli bottom="10" left="10" />
<mx:Move id="moveEffect" target="{toc}"/>
<mx:WipeLeft id="showTOC" target="{toc}"/>
<mx:WipeRight id="hideTOC" target="{toc}"/>
</mx:Canvas>
转载:http://1984yifeng.blog.163.com/blog/static/4728439120103232574073/
2766

被折叠的 条评论
为什么被折叠?



