ArcGIS For Flex地图联动
来源:互联网 发布:淘宝卖家扣分 编辑:程序博客网 时间:2024/05/20 01:08
1地图联动介绍
是针对Map对象,利用观察者模式,当鼠标进入某一Map时,此Map对象成为主体,其他的Map对其进行观察,若其当前视图范围改变,其他Map随其而动,同时取消对该Map对象的监听。
2具体实现
Map对象具有EXTENT_CHANGE事件
(com.esri.ags.events.ExtentEvent中),监听此事件进行观察。
3具体代码
package Hymn
{
import com.esri.ags.Map;
import com.esri.ags.events.ExtentEvent;
import flash.events.MouseEvent;
publicclass LinkingMethodsClass
{
publicfunction LinkingMethodsClass()
{
MapItems = new Array();
}
privatevar MapItems:Array;
/**
<p>功能:添加需要联动地图对象。</p>
<p>参数:
MapItem Map对象</p>
<p>返回值:无</p>
*/
publicfunction AddMap(MapItem:Map):void
{
for each(var Mapadded:Mapinthis.MapItems)
{
if(Mapadded ==MapItem)
{
return;
}
}
MapItems.push(MapItem);
AddLinkingStartFunction(MapItem);
}
privatefunction AddLinkingStartFunction(MapItem:Map):void
{
MapItem.addEventListener(MouseEvent.MOUSE_OVER,CheckExtentStartFunction);
}
privatefunction CheckExtentStartFunction(event:MouseEvent):void
{
var MapItem:Map = event.currentTargetas Map;
addLinkingFunction(MapItem);
}
privatefunction addLinkingFunction(MapItem:Map):void
{
MapItem.addEventListener(ExtentEvent.EXTENT_CHANGE,DoLinkingFunction);
}
privatefunction DoLinkingFunction(event:ExtentEvent):void
{
var MapItem:Map = event.currentTargetas Map;
RemoveLinkingFunction();
addLinkingFunction(MapItem);
for each(var MapValue:Mapinthis.MapItems)
{
if(MapValue!=MapItem)
{
MapValue.extent = MapItem.extent;
}
}
}
privatefunction RemoveLinkingFunction():void
{
for each(var MapItem:Mapinthis.MapItems)
{
MapItem.removeEventListener(ExtentEvent.EXTENT_CHANGE,DoLinkingFunction);
}
}
}
}
4 应用示例
新建Flex工程后,将以下代码粘贴覆盖主运行程序中的代码。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
creationComplete="Intial(event)"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955"
minHeight="600" xmlns:esri="http://www.esri.com/2008/ags">
<fx:Script>
<![CDATA[
import Hymn.LinkingMethodsClass;
import mx.events.FlexEvent;
privatevar MapLikingItem:LinkingMethodsClass
protectedfunction Intial(event:FlexEvent):void
{
// TODO Auto-generated method stub
MapLikingItem = new LinkingMethodsClass();
MapLikingItem.AddMap(this.MapItem1);
MapLikingItem.AddMap(this.MapItem2);
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<esri:Map id="MapItem1">
<esri:ArcGISTiledMapServiceLayer
url="http://hanym-pc/ArcGIS/rest/services/地形图/MapServer"/>
</esri:Map>
<esri:Map id="MapItem2">
<esri:ArcGISTiledMapServiceLayer
url="http://hanym-pc/ArcGIS/rest/services/地形图/MapServer"/>
</esri:Map>
</s:VGroup>
</s:Application>
- ArcGIS For Flex地图联动
- ArcGIS for JavaScript实现地图联动
- Arcgis for flex 调用百度地图与Google地图
- ArcGIS API for JavaScript实现地图双屏联动
- Arcgis for Javascript实现两个地图的联动
- ArcGIS API for JavaScript实现地图双屏联动
- ArcGIS API for JavaScript实现地图双屏联动
- ArcGIS API for Flex (使用ArcGIS API for Flex 创建一个新的地图项目)
- Flex 地图联动
- arcgis server for flex 获取地图图层
- 自定义ArcGIS Server API for Flex 地图提示窗体
- 地图上嵌入图片 - ArcGIS for FLEX API
- 地图中的BI图表解决方案(ArcGIS API for Flex)
- 自定义ArcGIS API for Flex 地图提示窗体
- 自定义ArcGIS API for Flex 地图提示窗体
- ArcGIS Server for flex地图控件的常用属性
- 地图自动缩放功能实现 arcgis for flex
- arcgis for flex 在地图上显示柱状图
- LeetCode:Majority Element
- SGU 495 Kids and Prizes 概率 二项分布
- 分析Java线程中断机制stop和interrupted的用法
- 多个storyboard 间的跳转
- 第17周项目1体会函数参数传递
- ArcGIS For Flex地图联动
- 记一次nginx崩溃
- ISO C90 forbids mixed declarations and code 警告
- 使用CocoaPods来管理iOS项目的依赖库
- 蓝桥杯测试试题 入门训练 圆的面积
- ant打包
- FrameLayout布局
- snoopy 采集
- 标准库:Allocator能做什么