对于开源WebGIS :我首选GeoServer+PostGIS+Openscales
下面开始Openscales1.2应用的简单入门
FlexApp.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%"
xmlns:os="http://openscales.org"
creationComplete="initMap();" resize="resizeMap()">
<fx:Style source="FlexApp.css"/>
<fx:Declarations>
</fx:Declarations>
<os:Map id="fxmap" width="100%" height="100%" zoom="5" center="4.833,45.767">
<os:WMSC name="Nasa" url="http://openscales.org/geoserver/gwc/service/wms" layers="bluemarble"
format="image/jpeg" maxExtent="-180,-90,180,90"/>
<os:WheelHandler/>
<!--图层管理器 -->
<os:ControlPanel title="图层管理器" x="{width - 225}" y="10" width="215">
<os:LayerManager />
</os:ControlPanel>
<!-- 鹰眼-->
<s:Panel id="miniMapPanel" title="Overview map" x="{width-miniMapPanel.width-10}" y="{height-miniMapPanel.height-10}">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<os:OverviewMap id="miniMap" width="100%" height="100%" extentColor="0xFF3300" newExtentColor="0x00FF33">
<os:CycleMap name="cyclemap" proxy="http://openscales.org/proxy.php?url="/>
</os:OverviewMap>
</s:Panel>
<!-- 比例尺 -->
<os:ScaleLine x="{10}" y="{height-80}" />
<!-- 显示鼠标坐标 -->
<os:MousePosition x="{fxmap.width / 2}"
y="{fxmap.height-20}"
displayProjection="EPSG:4326"/>
<!-- 导航控件1 -->
<os:PanZoom map="{map}"
x="{fxmap.x+10}"
y="{fxmap.y+10}" width="112" height="126"/>
</os:Map>
<!--导航控件2
<os:ControlPanel x="10" y="200" width="140" title="Navigation2">
<os:Pan map="{map}"/>
<mx:HBox width="100%" paddingLeft="5" paddingRight="5">
<os:Zoom map="{map}"/>
<mx:Spacer width="100%" />
<os:ZoomBox map="{map}" width="32" height="32"/>
</mx:HBox>
</os:ControlPanel>
-->
<!-- 工具栏 -->
<os:ControlPanel x="100" height="57" y="10" title="工具栏">
<os:layout>
<s:HorizontalLayout/>
</os:layout>
<mx:Button id="zoomInBtn" click="doMap('zoomin')" label="放大"/>
<mx:Button id="zoomOutBtn" click="doMap('zoomout')" label="缩小"/>
<mx:Button id="fullExtentBtn" click="{map.zoomToMaxExtent()}" label="全屏"/>
<mx:Button id="panBtn" click="doMap('pan')" label="漫游"/>
<mx:Button id="prevExtentBtn" click="{navToolbar.zoomToPrevExtent()}" label="前一视图"/>
<mx:Button id="nextExtentBtn" click="{navToolbar.zoomToNextExtent()}" label="后一视图"/>
</os:ControlPanel>
<fx:Script>
<![CDATA[
import org.openscales.core.Map;
import org.openscales.core.Trace;
import org.openscales.core.feature.Marker;
import org.openscales.core.feature.CustomMarker;
import org.openscales.core.feature.PointFeature;
import org.openscales.core.layer.FeatureLayer;
import org.openscales.core.popup.Anchored;
import org.openscales.core.style.Style;
import org.openscales.geometry.Point;
import org.openscales.geometry.basetypes.Location;
import org.openscales.proj4as.ProjProjection;
import toolbars.Navigation;
[Bindable] private var map:Map = null;
public var markLyon:Marker;
[Bindable] public var displayTrace:Boolean=false;
[Bindable] public var displayFirebugTrace:Boolean=false;
private var navToolbar:Navigation=new Navigation();
private function initMap():void {
Trace.useFireBugConsole=displayFirebugTrace;
map = fxmap.map;
this.navToolbar.map=map;
var markers:FeatureLayer = new FeatureLayer("customMarkerLayer");
//添加默认标记
markers.projection = new ProjProjection("EPSG:4326");
markers.generateResolutions(19);
markers.style = Style.getDefaultPointStyle();
var marker:PointFeature = PointFeature.createPointFeature(new Location(-94.49783,40.51800));
markers.addFeature(marker);
//markers.addFeature(CustomMarker.createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png",new Location(-94.49783,40.51800)));
//添加标记,绑定事件弹出气泡
var lonlat:Location = new Location(-95.49783,42.51800, ProjProjection.getProjProjection("EPSG:4326"));
markLyon = new Marker(new org.openscales.geometry.Point(lonlat.lon, lonlat.lat), {popupContentHTML: "This is a popup<br /><b>Bold text</b><br /><u>Link to <a href=\"http://openscales.org\" target=\"_new\">OpenScales</a></u>"});
markLyon.addEventListener(MouseEvent.CLICK, showPopup);
markers.addFeature(markLyon);
map.addLayer(markers);
var vect:FeatureLayer = new FeatureLayer("Reprojected vector");
vect.projection = ProjProjection.getProjProjection("EPSG:4326");
vect.style = Style.getDefaultPointStyle();
var p:org.openscales.geometry.Point = new org.openscales.geometry.Point(lonlat.lon, lonlat.lat);
vect.generateResolutions(19);
vect.addFeature(new PointFeature(p));
map.addLayer(vect);
}
private function doMap(tool:String):void{
navToolbar.activate(tool);
}
private function resizeMap():void {
miniMap.height = 0.2 * this.height;
miniMap.width = this.width * miniMap.height / this.height;
}
private function showPopup(e:MouseEvent):void {
var popup:Anchored = new Anchored();
popup.feature = markLyon;
map.addPopup(popup, true);
}
]]>
</fx:Script>
</s:Application>
效果如图:
本例实现了地图的基本功能包括:导航栏、工具栏、图层管理器、鹰眼、比例尺、鼠标坐标显示、标注气泡显示等。
- 大小: 94.6 KB
分享到:
相关推荐
openscales-openscales
OpenScales图层控制功能 DataGrid显示图层信息 包含checkBox控制图层显示列 图层上下移动功能 解决选择行上下移动时复选框状态改变的情况
OpenScales访问GeoWebCache的切片 原理:通过扩展OpenScales中的org.openscales.core.tile.Tile.Grid类来实现OpenScales访问GeoWebCache产生的切片
OpenScales学习
openscales 示例,里面是工程,可以用eclipse或者flash builder直接加载,如果跑不起来的话,可以配合openscales官网的例子配合起来用。
OpenScales是一个优秀的前台地图框架,开发者可以用来开发各种网络版、手机版和桌面版的地图程序。 她是基于ActionSctip 3 和 Flex写的,能够支持各种标准的地图服务,比如WMS、WFS、TMS、OSM等。 她是开源的、免费...
如何基于openscalse开发地图应用
openscales 目前最新开发开源包 附有事例 1.2-beta3
OpenScales2.2 Map.as 适用于OpenScales移动项目
openScale 的自我介绍中,就提到 openLayer ,感觉真的和网上说的一样: openScale 是 对openLayer 的AS 翻译。 openLayer 相当牛逼,个人觉得……与 google map 的JS版对比。openLayer 将我所能想到的地图操作都加...
openscales开发工具包 openscales开发工具包
OpenScales代码结构分析 说的还行
OpenScales基本功能事例 一些简单的 小例子
最新的openscales 参考示例工程,flex语言,显示与操作地图
参照openscales已有的一些Handler,自己写了一个Navigation,用来实现地图的放大、缩小、漫游、全屏显示、前后视图等功能,来完善openscales地图的基本操作。 大概的思路是,参照ZoomBoxHandler,写一个...
openscales 自定义工具包括放大缩小等 openscales 本身并没有这样的接口,本例是通过实现自定义的接口来达到放大缩小效果的。
用于openscales 绘制热度图 , 该类是一个lib 项目,可以下载下来进行 使用
用Flash Builder和openscales创建地图实例,本人折腾了老半天才整出来的(其实偶是小白),提供给初学者使用。。。
NULL 博文链接:https://liuyanbei12.iteye.com/blog/1157185