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)讲解(九)地图定位模块的更多相关文章

  1. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(一)GIS一张图的系统开发环境以及flexviewer框架

    系统的GIS功能实现是基于arcgis api for flex,首先附上系统的主界面图,接下来的是对主界面的模块功能详细讲解: 一.GIS环境软件安装 (1)arcgis desktop的安装,要是 ...

  2. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十)态势标绘模块

    config.xml文件的配置如下: <widget label="态势标绘" icon="assets/images/impact_area_over.png&q ...

  3. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(八)资源搜索模块

    config.xml文件的配置如下: <widget label="资源搜索" icon="assets/images/public_impact_over.png ...

  4. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(二)鹰眼模块

    讲解GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...

  5. 天津政府应急系统之GIS一张图(arcgis api for flex)解说(二)鹰眼模块

    解说GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...

  6. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十三)台风模块

    config.xml文件的配置如下: <widget label="台风" icon="assets/images/typhoon.png" config ...

  7. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十一)路径导航模块

    config.xml文件的配置如下: <widget label="路径导航" icon="assets/images/lujingdaohang.png" ...

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

    config.xml文件的配置如下: <widget label="地图搜索" icon="assets/images/emergency_resource_ove ...

  9. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(四)地图导航控件模块

    config.xml文件的配置如下: <widget left="10" top="50" config="widgets/Navigation ...

  10. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(三)显示地图坐标系模块

    config.xml文件的配置如下: <widget left="3" bottom="3" config="widgets/Coordinat ...

随机推荐

  1. Android 生成LayoutInflater的三种方式

    通俗的说,inflate就相当于将一个xml中定义的布局找出来. 因为在一个Activity里如果直接用findViewById()的话,对应的是setConentView()的那个layout里的组 ...

  2. 通过HTTP协议上传文件

         HTTP是很常见的协议,虽然用得很多,但对细节的了解却是很浅,这回通过向服务端上传文件信息来理解细节.网络库的选择:1.WinHTTP是windows下常用的库:2.CURL是广受喜爱的开源 ...

  3. android给View设置上下左右边框

    给View控件设置边框,可以动态设置上下左右.通过布局文件就能搞定 1.在drawable文件夹下新建一个shape_main_list_bg.xml文件 <layer-list xmlns:a ...

  4. MySQL学习笔记十六:锁机制

    1.数据库锁就是为了保证数据库数据的一致性在一个共享资源被并发访问时使得数据访问顺序化的机制.MySQL数据库的锁机制比较独特,支持不同的存储引擎使用不同的锁机制. 2.MySQL使用了三种类型的锁机 ...

  5. Objective-C中的属性机制

    Objective-C 2.0中的属性机制为我们提供了便捷的获取和设置实例变量的方式,也可以说属性为我们提供了一个默认的设置器和访问器的实现.在学习OC中属性之前我们先要知道为什么要为变量实现gett ...

  6. Openfire/XMPP学习之——Openfire的安装、配置

    一.Openfire下载: 官方下载:http://www.igniterealtime.org/downloads/index.jsp 在官方下载站点,可以获取Windows.Linux.Mac三种 ...

  7. iOS开发——高级特性&Runtime运行时特性详解

    Runtime运行时特性详解 本文详细整理了 Cocoa 的 Runtime 系统的知识,它使得 Objective-C 如虎添翼,具备了灵活的动态特性,使这门古老的语言焕发生机.主要内容如下: 引言 ...

  8. iOS 如何自定义UISearchBar 中textField的高度

    iOS 如何自定义UISearchBar 中textField的高度 只需设置下边的方法就可以 [_searchBar setSearchFieldBackgroundImage:[UIImage i ...

  9. 1Z0-053 争议题目解析694

    1Z0-053 争议题目解析694 考试科目:1Z0-053 题库版本:V13.02 题库中原题为: 694.As part of archiving the historical data, you ...

  10. DotNet指定文件显示的尺寸

    在项目中开发中,有时候需要将文件的尺寸进行控制,例如需要将文件的尺寸指定为字节,TB等.现在提供一个方法,实现将指定文件的尺寸, 提供:"字节", "KB", ...