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. OpenCASCADE Curve Length Calculation

    OpenCASCADE Curve Length Calculation eryar@163.com Abstract. The natural parametric equations of a c ...

  2. 深入理解脚本化CSS系列第五篇——动态样式

    前面的话 很多时候,DOM操作比较简单明了,因此用javascript生成那些通常原本是HTML代码生成的内容并不麻烦.但由于浏览器充斥着隐藏的陷阱和不兼容问题,处理DOM中的某些部分时要复杂一些,比 ...

  3. Hibernate4.0之HibernateSessionFactory源码详解

    import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.cfg.Conf ...

  4. Web APi之EntityFramework【CRUD】(三)

    前言 之前我们系统学习了EntityFramework,个人觉得有些东西不能学了就算完了,必须要学以致用,在Web API上也少不了增(C).删(D).改(U).查(R).鉴于此,我们通过EF来实现W ...

  5. MySQL学习笔记八:日期/时间的处理

    MySQL日期时间的处理,在其官网文档上都有详细的阐述,想了解更多的同学可自行查阅. 1.查询当前日期时间:函数有now(),localtime(),current_timestamp(),sysda ...

  6. 用队列模拟jquery的动画算法

    Aaron最近疯狂的爱上了算法研究,估计又要死伤不少脑细胞了,我喜欢捡现成的,可以省些力气.发现他写的一段源码,运行一下,还蛮好玩的,于是拿来分析一下,一来吸收下里边的营养,二来加深一下源码学习的功力 ...

  7. geotrellis使用(二十二)实时获取点状目标对应的栅格数据值

    目录 前言 实现方法 总结 一.前言        其实这个功能之前已经实现,今天将其采用1.0版的方式进行了重构与完善,现将该内容进行总结.        其实这个功能很常见,比如google地球上 ...

  8. 【Java心得总结二】浅谈Java中的异常

    作为一个面向对象编程的程序员对于 下面的一句一定非常熟悉: try { // 代码块 } catch(Exception e) { // 异常处理 } finally { // 清理工作 } 就是面向 ...

  9. (十六)WebGIS中偏移补偿量引发的问题之探讨

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 在上一章里讲解地图平移功能的实现时,我在最后提出了两个问题: ...

  10. 一步一步拆解一个简单的iOS轮播图(三图)

    导言(可以不看): 不吹不黑,也许是东半球最简单的iOS轮播图拆分注释(讲解不敢当)了(tree new bee).(一句话包含两个人,你能猜到有谁吗?提示:一个在卖手机,一个最近在卖书)哈哈... ...