arcgis api for flex 开发入门(二)map 的创建
来源:互联网 发布:重庆生活频道 网络直播 编辑:程序博客网 时间:2024/04/24 11:22
在flex 中创建一个esri 的map ,你只需要使用<esri:Map>标签就可以轻松完成。
在<esri:Map>标签中可以添加属性和响应事件的消息。
如下:
<esri:Map width="100%" height="50%" id="EsriMap" creati resize="EsriMapResize(event);" extentChange="ESRIMapExtentChange(event);" mouseMove="OnDrawMouseMove(event)" />
width和 height定义的map 的大小,id="EsriMap" 唯一标识了这个map。
针对map 的消息也有很多,最常用的就是creationComplete,resize和鼠标消息了。
现在我们map有了,那么我们如何让她显示数据呢,这就需要给 <esri:Map>标签添加一个layer 子标签 。
在ags flex api 中有以下几种类型的layer。
ArcGISDynamicMapServiceLayer :Allows you to work with a dynamic map service resource exposed by the ArcGIS Server REST API.
ArcGISImageServiceLayer: Allows you to work with an image service resource exposed by the ArcGIS Server REST API.
ArcGISMapServiceLayer :The base class for ArcGIS Server map services.
ArcGISTiledMapServiceLayer :Allows you to work with a cached map service resource exposed by the ArcGIS Server REST API.
ArcIMSMapServiceLayer :Allows you to work with an ArcIMS image service.
GPResultImageLayer :Allows you to view a geoprocessing task result identified by jobId and parameterName.
GraphicsLayer: A layer that contains one or more Graphic features.
其中GraphicsLayer是支持客户端添加Graphic features的图层,需要在客户端表现的,或者交互操作中产生的要素都要加到这个layer 上。
下面,我们就添加一个ArcGISTiledMapServiceLayer和GraphicsLayer到map 上。
<esri:Map width="100%" height="50%" id="EsriMap" creati resize="EsriMapResize(event);" extentChange="ESRIMapExtentChange(event);" mouseMove="OnDrawMouseMove(event)" >
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
<esri:GraphicsLayer id="myGraphicsLayer" spatialReference="{sr}"/>
</esri:Map>
其中<esri:ArcGISTiledMapServiceLayer>标签中的url 属性为提供该服务的地址。<esri:GraphicsLayer>标签其中的spatialReference属性定义了该图层的空间参考系。
创建一个空间参考系,只需要使用<esri:SpatialReference>标签就可以了,其中wkid 是esri已经定义好的空间草考系的ID,具体ID对应的空间参考可以在http://resources.esri.com/help/9.3/arcgisserver/apis/REST/index.html?gcs.html中查找。如下为创建一个kid="4326"的空间参考系。
<esri:SpatialReference id="sr" wkid="4326"/>
那么,我们如何定义我们想显示的范围呢?
很简单,在<esri:Map>下面添加<esri:extent>子标签,我们就可以来控制当前的显示范围了。
<esri:extent>
<esri:Extent id = "esriMapExtent" xmin="116" ymin="39.5" xmax="116.5" ymax="40.5"/>
</esri:extent>
其中x是经度,y 是纬度。
这样一个北京地区的map 就可以显示到我们面前了。
在<esri:Map>标签中可以添加属性和响应事件的消息。
如下:
<esri:Map width="100%" height="50%" id="EsriMap" creati resize="EsriMapResize(event);" extentChange="ESRIMapExtentChange(event);" mouseMove="OnDrawMouseMove(event)" />
width和 height定义的map 的大小,id="EsriMap" 唯一标识了这个map。
针对map 的消息也有很多,最常用的就是creationComplete,resize和鼠标消息了。
现在我们map有了,那么我们如何让她显示数据呢,这就需要给 <esri:Map>标签添加一个layer 子标签 。
在ags flex api 中有以下几种类型的layer。
ArcGISDynamicMapServiceLayer :Allows you to work with a dynamic map service resource exposed by the ArcGIS Server REST API.
ArcGISImageServiceLayer: Allows you to work with an image service resource exposed by the ArcGIS Server REST API.
ArcGISMapServiceLayer :The base class for ArcGIS Server map services.
ArcGISTiledMapServiceLayer :Allows you to work with a cached map service resource exposed by the ArcGIS Server REST API.
ArcIMSMapServiceLayer :Allows you to work with an ArcIMS image service.
GPResultImageLayer :Allows you to view a geoprocessing task result identified by jobId and parameterName.
GraphicsLayer: A layer that contains one or more Graphic features.
其中GraphicsLayer是支持客户端添加Graphic features的图层,需要在客户端表现的,或者交互操作中产生的要素都要加到这个layer 上。
下面,我们就添加一个ArcGISTiledMapServiceLayer和GraphicsLayer到map 上。
<esri:Map width="100%" height="50%" id="EsriMap" creati resize="EsriMapResize(event);" extentChange="ESRIMapExtentChange(event);" mouseMove="OnDrawMouseMove(event)" >
<esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
<esri:GraphicsLayer id="myGraphicsLayer" spatialReference="{sr}"/>
</esri:Map>
其中<esri:ArcGISTiledMapServiceLayer>标签中的url 属性为提供该服务的地址。<esri:GraphicsLayer>标签其中的spatialReference属性定义了该图层的空间参考系。
创建一个空间参考系,只需要使用<esri:SpatialReference>标签就可以了,其中wkid 是esri已经定义好的空间草考系的ID,具体ID对应的空间参考可以在http://resources.esri.com/help/9.3/arcgisserver/apis/REST/index.html?gcs.html中查找。如下为创建一个kid="4326"的空间参考系。
<esri:SpatialReference id="sr" wkid="4326"/>
那么,我们如何定义我们想显示的范围呢?
很简单,在<esri:Map>下面添加<esri:extent>子标签,我们就可以来控制当前的显示范围了。
<esri:extent>
<esri:Extent id = "esriMapExtent" xmin="116" ymin="39.5" xmax="116.5" ymax="40.5"/>
</esri:extent>
其中x是经度,y 是纬度。
这样一个北京地区的map 就可以显示到我们面前了。
完整代码如下
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Using ArcGIS API for Flex to connect to a cached ArcGIS Online service" styleName="plain"> <esri:SpatialReference id="sr" wkid="4326"/> <esri:Map crosshairVisible="true"> <esri:extent> <esri:Extent id = "esriMapExtent" xmin="116" ymin="39.5" xmax="116.5" ymax="40.5"/> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" /> <esri:GraphicsLayer id="myGraphicsLayer" spatialReference="{sr}"/> </esri:Map></mx:Application>
- arcgis api for flex 开发入门(二)map 的创建
- arcgis api for flex 开发入门(二)map 的创建
- ArcGIS API for Flex (使用ArcGIS API for Flex 创建一个新的地图项目)
- arcgis api for flex 开发入门(一)环境搭建
- arcgis api for flex 开发入门(五)查询
- arcgis api for flex 开发入门(一)环境搭建
- arcgis api for flex 开发入门(一)环境搭建
- arcgis api for flex 开发入门(五)查询
- arcgis api for flex 开发入门(六)identify
- arcgis api for flex 开发入门(三)地图浏览控件的使用
- arcgis api for flex 开发入门(四)Darw控件的使用
- arcgis api for flex 开发入门(三)地图浏览控件的使用
- arcgis api for flex 开发入门(四)Darw控件的使用
- arcgis api for flex 开发入门(七)Geometry service 的使用
- arcgis api for flex 开发入门(八)GP服务的使用
- arcgis api for flex 开发入门(九)webservices 的使用
- arcgis api for flex 高级主题(二) 自定义控件的开发
- arcgis api for flex之二、开发环境配置
- 【Android 开发】:UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
- 在Linux中开机自动运行普通用户脚本程序
- test
- arcgis api for flex 开发入门(一)环境搭建
- 用Visual C++.NET进行GDI+编程
- arcgis api for flex 开发入门(二)map 的创建
- getch
- uva 10905-Children’s Game
- WSAEventSelect模型中FD_READ 网络事件的处理
- 数据库分库分表(sharding)系列
- POJ | 1065 Wooden Sticks | 贪心
- RIA Service部署IIS6 - WIN2003
- arcgis api for flex 开发入门(三)地图浏览控件的使用
- qt编译不识别tslib报找不到问题的解决