天津政府应急系统之GIS一张图(arcgis api for flex)讲解(九)地图定位模块
config.xml文件的配置如下:
<widget label="地图定位" config="widgets/esri/Location/LocationWidget.xml"
icon="assets/images/ditudingwei.png" url="widgets/esri/Location/LocationWidget.swf" />
源代码目录如下:
界面效果:
大概的思路如下:定位有两种方式:1.后台数据库关联的,即是从后台数据库读取事故列表的定位数据,然后加载出来显示在地图上;2.直接在地图上点击某处,获取该处的定位点信息。两者的共同点都是根据经纬度来定位。
LocationWidget.xml:配置数据库事故列表的字段信息
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- <icon>assets/images/i_target.png</icon>-->
<icon>assets/images/Red_glow.swf</icon>
<title>{name}</title>
<fields>
<field name="type" alias="事件类别" visible="true" />
<field name="event_level_display" alias="事件级别" visible="true" />
<field name="event_level" alias="事件级别Id" visible="false" />
<field name="event_time" alias="事发时间" visible="true" />
<field name="event_man" alias="联系人" visible="true" />
<field name="event_status" alias="状态" visible="false" />
<field name="event_status_display" alias="状态" visible="true" />
</fields>
</configuration>
LocationWidget.mxml:这里截取核心实现部分
protected function list1_clickHandler(event:ListEvent):void
{
graphicsLayer.clear();
// TODO Auto-generated method stub
var graphic:Graphic=lstEvent.selectedItem as Graphic;//获取事故列表某项数据,转换graphic
if(graphic.attributes.X==0 || graphic.attributes.Y==0){//判断事故定位数据是否合法
Alert.show("此事件没有坐标信息,");
}else{
zoomToFeature(graphic);//跳转到定位函数
} }
//定位函数
private function zoomToFeature(feature:Graphic):void{
var mapPoint:MapPoint = feature.geometry as MapPoint;//获取经纬度
mapPoint.spatialReference=new SpatialReference(4326);
this.longitudeText.text="";
this.latitudeText.text="";
longitudeText.text="经度:"+mapPoint.x.toFixed(4).toString();
latitudeText.text="纬度:"+mapPoint.y.toFixed(4).toString();
// var popUpRenderer:CustomPopUpRenderer=new CustomPopUpRenderer();
var popUpRenderer:PopUpRenderer=new PopUpRenderer();//设置气泡窗口
//popUpRenderer.forceSetMap(this._featureLayer.map);
var popUpInfo:PopUpInfo=(this.graphicLayer.infoWindowRenderer as ClassFactory).properties.popUpInfo;
popUpInfo.showZoomToButton=true;
popUpRenderer.popUpInfo=popUpInfo;
popUpRenderer.graphic=feature;
// if(!popUpRenderer.map)popUpRenderer.userMap=this.map;
this.map.infoWindow.content=popUpRenderer;
this.map.level=7;
this.map.zoomTo(feature.geometry);
this.map.infoWindow.show(mapPoint);
this.addSharedData("event_point", new ArrayCollection([mapPoint]));
var message:String="确定接入点,坐标为:x=" + mapPoint.x + " y=" + mapPoint.y;
doBufferByPoint(mapPoint);
} //添加分析的方法 start
private var lastDrawGraphic:Graphic;
private function doBufferByPoint(mapPoint:MapPoint):void
{
var base:Number=Number(500);
var classNumber:Number=Number(1);
var interval:Number=Number(500);
var distances:Array=[];
if (classNumber >= 1)
{
for (var i:int=0; i < classNumber; i++)
{
distances.push(base + i * interval);
}
}
doBuffer(mapPoint, distances); } private function doBuffer(geometry:Geometry, distances:Array):void
{
var radius:Number=Number(500);
var param:BufferParameters=new BufferParameters();
param.geometries=[geometry];
param.distances=distances;
//param.geodesic=true;
//4326需要加上这个单位
param.unit=GeometryService.UNIT_METER;
//param.outSpatialReference=new SpatialReference(4326);
geometryService.buffer(param); lastDrawGraphic = new Graphic(geometry);
var label:String = "面积:" + numFormatter.format(3.14*radius*radius/1000000) + "平方千米";
label += "\n" + "半径:" + numFormatter.format(radius/1000) + "千米";
addDrawLabel(label, lastDrawGraphic);
} private function addDrawLabel(label:String, lastDrawnGraphic:Graphic):void
{
var txtSym:TextSymbol = new TextSymbol(label);
txtSym.yoffset = 8;
var txtFormat:TextFormat = new TextFormat("Arial", 12, 0x000000, true); // black label
txtSym.textFormat = txtFormat;
lastDrawnGraphic.symbol = txtSym;
}
备注:
GIS技术交流QQ群:432512093
WebGIS二次开发培训入门群: 238339408
天津政府应急系统之GIS一张图(arcgis api for flex)讲解(九)地图定位模块的更多相关文章
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(一)GIS一张图的系统开发环境以及flexviewer框架
系统的GIS功能实现是基于arcgis api for flex,首先附上系统的主界面图,接下来的是对主界面的模块功能详细讲解: 一.GIS环境软件安装 (1)arcgis desktop的安装,要是 ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十)态势标绘模块
config.xml文件的配置如下: <widget label="态势标绘" icon="assets/images/impact_area_over.png&q ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(八)资源搜索模块
config.xml文件的配置如下: <widget label="资源搜索" icon="assets/images/public_impact_over.png ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(二)鹰眼模块
讲解GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)解说(二)鹰眼模块
解说GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十三)台风模块
config.xml文件的配置如下: <widget label="台风" icon="assets/images/typhoon.png" config ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十一)路径导航模块
config.xml文件的配置如下: <widget label="路径导航" icon="assets/images/lujingdaohang.png" ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(六)地图搜索模块
config.xml文件的配置如下: <widget label="地图搜索" icon="assets/images/emergency_resource_ove ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(四)地图导航控件模块
config.xml文件的配置如下: <widget left="10" top="50" config="widgets/Navigation ...
- 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(三)显示地图坐标系模块
config.xml文件的配置如下: <widget left="3" bottom="3" config="widgets/Coordinat ...
随机推荐
- 使用HTML5里的classList操作CSS类
在HTML5 API里,页面DOM里的每个节点上都有一个classList对象,程序员可以使用里面的方法新增.删除.修改节点上的CSS类.使用classList,程序员还可以用它来判断某个节点是否被赋 ...
- lintcode循环数组之连续子数组求和
v 题目:连续子数组求和 II 给定一个整数循环数组(头尾相接),请找出一个连续的子数组,使得该子数组的和最大.输出答案时,请分别返回第一个数字和最后一个数字的值.如果多个答案,请返回其中任意一个. ...
- 应用程序框架实战二十一:DDD分层架构之仓储(介绍篇)
前面已经介绍过Entity Framework的工作单元和映射层超类型的封装,从本文开始,将逐步介绍仓储以及对查询的扩展支持. 什么是仓储 仓储表示聚合的集合. 仓储所表现出来的集合外观,仅仅是一种模 ...
- 编写简单的ramdisk(无请求队列)
最近在研究块设备驱动的编写,看了赵磊大牛的<写一个块设备驱动>,受益匪浅,虽然能看懂里面说的,但动手写写代码还是能加深理解的,下面实现的ramdisk写的很简单,如果有错误,欢迎大牛们指正 ...
- [OpenCV] Samples 13: opencv_version
cv::CommandLineParser的使用. I suppose CommandLineParser::has("something") should be true whe ...
- Fragment基础----创建
1,Fragment的目的及应用场景 fragment 是3.0后引入的类,其字面翻译为“碎片”. 目的是将activity划分成许多单元再进行组合,可以根据不同分辨率屏幕,在不同状态下,灵活创建优化 ...
- Android中Fragment+ViewPager的配合使用
官方推荐 ViewPager与Fragment一起使用,可以更加方便的管理每个Page的生命周期,这里有标准的适配器实现用于ViewPager和Fragment,涵盖最常见的用例.FragmentPa ...
- Windows Phone 如何在程序中播放提示声音?
在Windows Phone 中播放提示音可以使用 Microsoft.Xna.Framework.Audio 命名空间下的 SoundEffect 类.具体使用方法如下: 1. 根据声音文件路径创建 ...
- MySQL PXC构建一个新节点只需IST传输的方法
需求场景:原有的pxc环境数据量已经比较大,新买的服务器要加入此集群中,如何让其用IST的方式传输,而不是SST. PXC传输数据有两种方式: IST: Incremental State Trans ...
- PgwSlideshow-基于Jquery的图片轮播插件
0 PgwSlideshow简介 PgwSlideshow是一款基于Jquery的图片轮播插件,基本布局分为上下结构,上方为大图轮播区域,用户可自定义图片轮播切换的间隔时间,也可以通过单击左右方向按键 ...