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. MongoDB 数据分发

    在MongoDB(版本 3.2.9)中,数据的分发是指将collection的数据拆分成块(chunk),分布到不同的分片(shard)上,数据分发主要有2种方式:基于数据块(chunk)数量的均衡分 ...

  2. jQuery源码分析系列(40): 动画设计

    前言 jQuery动画是通过animate这个API设置执行的,其内部也是按照每一个animate的划分封装了各自动画组的行为, 包括数据过滤.缓动公式.一些动画默认参数的设置.元素状态的调整.事件的 ...

  3. 一张图理解prototype、proto和constructor的三角关系

    × 目录 [1]图示 [2]概念 [3]说明[4]总结 前面的话 javascript里的关系又多又乱.作用域链是一种单向的链式关系,还算简单清晰:this机制的调用关系,稍微有些复杂:而关于原型,则 ...

  4. 比较一下以“反射”和“表达式”执行方法的性能差异

    由于频繁地使用反射会影响性能,所以ASP.NET MVC采用了表达式树的方式来执行目标Action方法.具体来说,ASP.NET MVC会构建一个表达式来体现针对目标Action方法的执行,并且将该表 ...

  5. Web API接口之FileReader

    Web API接口之FileReader *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...

  6. ASP.NET Web API 异常日志记录

    如果在 ASP.NET MVC 应用程序中记录异常信息,我们只需要在 Global.asax 的 Application_Error 中添加代码就可以了,比如: public class MvcApp ...

  7. 分享一个 @user 前端插件

    开源地址:https://github.com/yuezhongxin/Mention.js 插件效果:类似于微博或 github 中 @user 列表效果. 这是个二次开发的插件,花了几天时间,对 ...

  8. 程序员眼中的 SQL Server-非聚集索引能给我们带来什么?

    写在前面 最近在做的一个项目,页面访问的时候很慢(大概几秒钟的样子),然后用日志记录的方式,来排查这个问题,最后发现是 Entity Framework 初始化的一个坑(大概要花 6-7 秒),详见: ...

  9. Global eval. What are the options?

    David Flanagan最近写了一个关于全局eval的简单表达式,可以用一行式子表示: var geval = this.execScript || eval; 尽管看起来很简短,但是跨浏览器的兼 ...

  10. Kooboo CMS - Html.FrontHtml[Helper.cs] 各个方法详解

    下面罗列了方法详解,每一个方法一篇文章. Kooboo CMS - @Html.FrontHtml().HtmlTitle() 详解 Kooboo CMS - Html.FrontHtml.Posit ...