天津政府应急系统之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 ...
随机推荐
- 异步方法不能使用ref和out的解决方法
异常处理汇总-后端系列:http://www.cnblogs.com/dunitian/p/4523006.html 应用场景==>后端现在都是用异步方法,那么分页是必不可少的,于是就有了这个问 ...
- jQuery源码分析系列(38) : 队列操作
Queue队列,如同data数据缓存与Deferred异步模型一样,都是jQuery库的内部实现的基础设施 Queue队列是animate动画依赖的基础设施,整个jQuery中队列仅供给动画使用 Qu ...
- JavaScript 面向对象继承的实现
<script type="text/javascript"> function Animal () { this.species="Animal" ...
- Android 对程序异常崩溃的捕捉
转载博客:http://blog.csdn.net/i_lovefish/article/details/17719081 以下为异常捕捉处理代码: import java.io.BufferedRe ...
- 纪念我曾经的 JAVA 姿势--转
原文地址:https://segmentfault.com/a/1190000007122432?hmsr=toutiao.io&utm_medium=toutiao.io&utm_s ...
- C/C++ char a[ ] 和 char *a 的差别,改变 char *a爆内存错误的原因
对于一些需要传入参数为 char * temp 指针类的函数: 我们定义一个 char a[10] 或char *a 传进去都是可以的. 但是, 如果该函数是会改变你所传入的参数的值时, 传入 cha ...
- 数据库操作提示:Specified key was too long; max key length is 767 bytes
操作重现: 法1:新建连接——>新建数据库——>右键数据库导入脚本——>提示:Specified key was too long; max key length is 767 by ...
- 求一个数组的最大子数组(C/C++实现)
最大子数组:要求相连,加起来的和最大的子数组就是一个数组的最大子数组.编译环境:VS2012,顺便说句其实我是C#程序员,我只是喜欢学C++. 其实这是个半成品,还有些BUG在里面,不过总体的思路是这 ...
- mybatis入门基础(二)----原始dao的开发和mapper代理开发
承接上一篇 mybatis入门基础(一) 看过上一篇的朋友,肯定可以看出,里面的MybatisService中存在大量的重复代码,看起来不是很清楚,但第一次那样写,是为了解mybatis的执行步骤,先 ...
- js树形控件—zTree使用总结
0 zTree简介 树形控件的使用是应用开发过程中必不可少的.zTree 是一个依靠 jQuery 实现的多功能 “树插件”.优异的性能.灵活的配置.多种功能的组合是 zTree 最大优点. 0.0 ...