基于ArcGIS API for Flex的区域性助老助残地图服务

原创 2013年12月04日 13:00:04
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:esri="http://www.esri.com/2008/ags"
			   xmlns:utils="utils.*"
			   xmlns:local="*"
			   pageTitle="助老助残室内位置服务"
			   minWidth="955" minHeight="600">
	<fx:Script>
		<![CDATA[
			import com.esri.ags.Graphic;
			import com.esri.ags.events.MapEvent;
			import com.esri.ags.events.MapMouseEvent;
			import com.esri.ags.geometry.MapPoint;
			import com.esri.ags.tasks.supportClasses.IdentifyParameters;
			import com.esri.ags.tasks.supportClasses.IdentifyResult;
			import mx.controls.Alert;
			import mx.rpc.AsyncResponder;
			import mx.rpc.events.FaultEvent;
			protected function pMap_mouseMoveHandler(event:MouseEvent):void
			{
				// TODO Auto-generated method stub
				const mapPoint:MapPoint = map2d.toMapFromStage(event.stageX,event.stageY);
				mapCoordinate.text = mapPoint.x.toFixed(1)+","+mapPoint.y.toFixed(1);
			}
			protected function pMap_loadHandler(event:MapEvent):void
			{
				// TODO Auto-generated method stub
				var timer:Timer = new Timer(1000);
				timer.addEventListener(TimerEvent.TIMER,onTimer);
				timer.start();
				var mapTimer:Timer = new Timer(10000);
				mapTimer.addEventListener(TimerEvent.TIMER,mapRefresh);
				mapTimer.start();
				map2d.infoWindow.addEventListener(Event.CLOSE,pMap_infoWindow_CloseHandler);
			}
			private function onTimer(event:TimerEvent):void{
				var date:Date = new Date();
				//txtDate.text = date.toString();
				txtDate.text = dateFormatter.format(date);
			}
			private function mapRefresh(event:TimerEvent):void{
				if(baseLayer!=null)
				{
					peopleLayer.refresh();
					peopleAlarmLayer.refresh();
					baseLayer.refresh();
					//watchLayer.refresh();
					//Alert.show("");
				}
			}
			protected function pMap_mapClickHandler(event:MapMouseEvent):void
			{
				//Alert.show(map2d.scale.toString());
				var identifyParams:IdentifyParameters = new IdentifyParameters();
				identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE;
				identifyParams.layerIds = [0,1];
				identifyParams.returnGeometry = true;
				identifyParams.tolerance = 5;
				identifyParams.width = map2d.width;
				identifyParams.height = map2d.height;
				identifyParams.mapExtent = map2d.extent;
				identifyParams.spatialReference = map2d.spatialReference;
				identifyParams.geometry = event.mapPoint;
				identifyTask.execute(identifyParams,new AsyncResponder(result_identityTask,fault_identityTask));
				
				function result_identityTask(results:Array,token:Object = null):void
				{
					highlightGraphicsLayer.clear();
					var count:int = results.length;
					if(results && count>0){
						var infoPoint:MapPoint = results[0].feature.geometry;
						for(var i:int = 0;i<count;i++){
							var result:IdentifyResult = results[i];
							var pGraphic:Graphic = result.feature;
							pMap_infoWindow_setContentHandler(pGraphic); // 设定信息窗口的显示字段
							highlightGraphicsLayer.add(new Graphic(result.feature.geometry,onSelectionMarker));
							break;
						}
						map2d.infoWindow.show(infoPoint);
					} else {
					}
				}
				function pMap_infoWindow_setContentHandler(graphic:Graphic):void{
					infoWindow.PID = graphic.attributes.PID;
					infoWindow.Name = graphic.attributes.Name;
					infoWindow.Gender = graphic.attributes.Gender;
					infoWindow.Age = graphic.attributes.Age;
					infoWindow.RoomNumber = graphic.attributes.RoomNumber;
				}
				function fault_identityTask(error:Object,token:Object = null):void{
					Alert.show(String(error),"Identity Error");
				}
			}
			private function pMap_infoWindow_CloseHandler(event:Event):void{
				highlightGraphicsLayer.clear();
			}
			protected function peopleLayer_faultHandler(event:FaultEvent):void
			{
				// TODO Auto-generated method stub
				peopleLayer.visible = false;
				Alert.show(event.fault.faultString + "\n\n" + event.fault.faultDetail, "FeatureLayer error " + event.fault.faultCode);
			}
		]]>
	</fx:Script>
		<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
		@namespace esri "http://www.esri.com/2008/ags";
		@namespace utils "utils.*";
		@namespace local "*";
		esri|InfoWindow{
			backgroundAlpha: 0.8;
			backgroundColor: #E9FFBE;
			borderThickness: 0;
			infoPlacement: top;
			shadowAlpha: 0.5;
			shadowDistance: 10;
			upperRightRadius: 0;
		}
	</fx:Style>
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
		<esri:SpatialReference id="mapSR"
							   wkid="2385" />
		<esri:Extent id="initExtent"
					 xmin="899275"
					 ymin="-170770" 
					 xmax="931980"
					 ymax="-138070"
					 spatialReference="{mapSR}" />
		<esri:IdentifyTask id="identifyTask"
						   concurrency="last"
						   showBusyCursor="true"
						   url="http://192.168.11.90:6080/arcgis/rest/services/Indoor/F20/MapServer" />
		<esri:SimpleMarkerSymbol id="onSelectionMarker"
								 size="10"
								 color="0xB0FFFF"
								 alpha="20" />
		<s:DateTimeFormatter id="dateFormatter"
							 useUTC="false"
							 dateTimePattern="YY-MM-DD h:mm:ss"
							 locale="zh-CN"
							 timeStyle="long" />
		<esri:InfoSymbol id="peopleInfoAlarmSymbol">
			<esri:infoRenderer>
				<fx:Component>
					<s:DataRenderer color="0xBEFFE8">
						<s:Label fontSize="12"
								 fontWeight="bold"
								 paddingBottom="3"
								 paddingLeft="3"
								 paddingRight="3"
								 paddingTop="3"
								 fontFamily="微软雅黑"
								 backgroundColor="0xBEFFE8"
								 color="0xFF5500"
								 text="{data.name}离开!" />
					</s:DataRenderer>
				</fx:Component>
			</esri:infoRenderer>
		</esri:InfoSymbol>
		<esri:InfoSymbol id="peopleInfoSymbol">
			<esri:infoRenderer>
				<fx:Component>
					<s:DataRenderer color="0xBEFFE8">
						<s:Label fontSize="12"
								 fontWeight="bold"
								 paddingBottom="3"
								 paddingLeft="3"
								 paddingRight="3"
								 paddingTop="3"
								 fontFamily="微软雅黑"
								 backgroundColor="0xBEFFE8"
								 color="0xFF5500"
								 text="{data.name}" />
					</s:DataRenderer>
				</fx:Component>
			</esri:infoRenderer>
		</esri:InfoSymbol>
	</fx:Declarations>
	<s:layout>
		<s:VerticalLayout />
	</s:layout>
	<esri:Map id="map2d"
			  logoVisible="false"
			  scaleBarVisible="false"
			  zoomSliderVisible="false"
			  width="100%"
			  height="100%"
			  extent="{initExtent}" 
			  scrollWheelZoomEnabled="false"
			  rubberbandZoomEnabled="false"
			  doubleClickZoomEnabled="false"
			  clickRecenterEnabled="false"
			  panEnabled="true"
			  keyboardNavigationEnabled="false"
			  mouseMove="pMap_mouseMoveHandler(event)"
			  mapClick="pMap_mapClickHandler(event)"
			  load="pMap_loadHandler(event)">
		<esri:ArcGISDynamicMapServiceLayer id="baseLayer"
										 url = "http://192.168.11.90:6080/arcgis/rest/services/Indoor/F20/MapServer" />
		<esri:FeatureLayer id="peopleAlarmLayer"
						   mode="onDemand"
						   outFields="[*]"
						   fault="peopleLayer_faultHandler(event)"
						   visible="true"
						   disableClientCaching="true"
						   symbol="{peopleInfoAlarmSymbol}"
						   url="http://192.168.11.90:6080/arcgis/rest/services/Indoor/F20/MapServer/1" /> <!-- OPM 报警位置 -->
		<esri:FeatureLayer id="peopleLayer"
						   mode="onDemand"
						   outFields="[*]"
						   fault="peopleLayer_faultHandler(event)"
						   visible="true"
						   disableClientCaching="true"
						   symbol="{peopleInfoSymbol}"
						   url="http://192.168.11.90:6080/arcgis/rest/services/Indoor/F20/MapServer/0" /> <!-- OPM 正常位置 -->
		<esri:GraphicsLayer id="highlightGraphicsLayer" />
		<esri:infoWindowContent>
			<utils:InfoWindow id="infoWindow" />
		</esri:infoWindowContent>
	</esri:Map>
	<s:Group>
		<s:layout>
			<s:HorizontalLayout />
		</s:layout>
		<s:RichText id="mapCoordinate"
					text="显示地图坐标"  />
		<s:RichText id="txtDate"
					text="显示时间"  />
	</s:Group>
</s:Application>

第一个项目顺利验收通过。
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

arcgis for flex api version3.7 教程:3.如何使用QueryTask查询地图服务

这篇介绍如何通过query task来从ArcGIS service中查询数据,分下面四步: 1  设置Map和GraphicsLayer. 2  使用query filter来设置QueryTa...

arcgis for flex api version3.7 教程:2.通过地图服务的ID添加地图

ArcGIS web map 可以说成是一个底图和一系列的可进行任务处理和交互的图层。地图显示形式丰富,可以是多级别显示的底图(basemap)、应用图层(operations layers)、弹出窗...

天津政府应急系统之GIS一张图(arcgis api for flex)讲解(九)地图定位模块

大概的思路如下:定位有两种方式:1.后台数据库关联的,即是从后台数据库读取事故列表的定位数据,然后加载出来显示在地图上;2.直接在地图上点击某处,获取该处的定位点信息。两者的共同点都是根据经纬度来定位...

ArcGIS api for flex读取下载到本机的google瓦片地图 web墨卡托投影

GoogeleLayer.as /** * @Description: * @Type:组件类 * @Copyright: Copyright 2013 * @Company: *...
  • neil89
  • neil89
  • 2013-10-23 16:28
  • 1895

arcgis for flex api version3.7 教程:5.使用Editor对地图进行编辑

ArcGIS的网络编辑操作(可以认为是网页端的相关地理处理操作)需要feature service来提供符号信息和几何数据信息。feature service允许你创建自定义的REST方法节点,用来存...

天津政府应急系统之GIS一张图(arcgis api for flex)讲解(六)地图搜索模块

config.xml文件的配置如下: 1 widget label="地图搜索" icon="assets/images/emergency_resource_over.png" 2 ...

arcgis for flex api version3.7 教程:9.地图范围extent的设置和使用

下面介绍的是设置地图范围的一系列方法,以及获取地图范围的方法。 如果在初始化地图时没有对地图范围进行设置,则将会使用默认的设置信息,它将会是所使用的地图文档中最后一次保存时的地图显示范围。如果使...

天津政府应急系统之GIS一张图(arcgis api for flex)讲解(五)地图切换以及图层显示模块

config.xml文件的配置如下: widget right="20" top="55" config="widgets/MapSwitcher/MapSwitcherWidget...

arcgis for flex api version3.7 教程:1.添加地图和图层

下面的步骤将引导你在你的flex应用中添加一个底图(basemap layer)。我们假设你已经建立了一个空白 的工程,已经引入了arcgis for flex api的库。没有引入自己去引入。 ...

ArcGis api for flex 中 Map控件的属性开关(地图控件的导航功能开关属性)

Xml代码   xml version="1.0" encoding="utf-8"?>          前提准备...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)