【学习笔记】GIS开发——配置OpenScales开发环境

学习教程[url]http://blog.csdn.net/dragoonnet/article/details/6334228[/url]配置的第一个工程。
代码和相关注释:

<?xml version="1.0" encoding="utf-8"?>
<!--
增加了一个命名空间:xmlns:os="http://openscales.org",使"os"的命名空间与OpenScales-fx库连接成功
-->
<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"
minWidth="955"
minHeight="600"
xmlns:os="http://openscales.org"
creationComplete="initMap();">

<fx:Declarations>
</fx:Declarations>
<!--
创建一个地图对象:
id 是唯一标示,这儿我们命名为fxmap.
width 和 height限制地图的大小.
zoom 设置地图开始的缩放等级.
center 代表地图居中的坐标.应该与基本层有相同的投影.
x 和 y 决定了地图空间在应用程序的位置.
-->
<os:Map id="fxmap"
width="500"
height="600"
center="-100.10929,40.48437"
zoom="3"
x="100"
y="100">

<!--
增加一个开放的街道地图(OSM)层:proxy 参数不是必须的,但是可以针对OSM服务器可以阻止安全错误,不合法的跨域操作等.
其他的街道层还有 : Cycle Map, Osmarender 都可以在地图作为OSM数据,只是他们有其他的渲染规则.
eg:<os:Osmarender name="base" proxy="http://www.openscales.org/proxy.php?url=" />
-->
<os:Mapnik name="base"
proxy="http://www.openscales.org/proxy.php?url=" />
<!--
KML层没有设置为基本层,所以它将在OSM层上面.
-->
<os:KML url="http://code.google.com/intl/fr/apis/kml/documentation/KML_Samples.kml" proxy="http://openscales.org/proxy.php?url=" numZoomLevels="20" style="{Style.getDefaultLineStyle()}"/>
<!--
鼠标事件:
鼠标滚轮缩放 (WheelHandler)
点击事件 (ClickHandler)
鼠标移动或者拖放事件 (DragHandler)
-->
<os:DragHandler id="dragHandler" active="true"/>
<os:WheelHandler/>
<!--鼠标焦点事件-->
<os:MousePosition x="10" y="{fxmap.height-20}" displayProjection="EPSG:4326"/>
<!--
OGC层的范例: Web Feature Service (WFS)¶
OGC(开放地理空间联盟)定义了类似WFS,WMS等多个协议
你在OpenScales-fx-example中可以找到很多关于OGC层的例子.下面是这个例子提供了网络要素服务作为基本层。
-->
<os:WFS name="Topp States (WFS)" url="http://openscales.org/geoserver/wfs" typename="topp:states" projection="EPSG:4326" version="1.0.0" style="{Style.getDefaultSurfaceStyle()}"/>
</os:Map>
<!--地图控制栏-->
<os:PanZoom map="{map}"
x="{fxmap.x+10}"
y="{fxmap.y+10}"/>

<fx:Script>
<![CDATA[
import org.openscales.core.Map;
import org.openscales.core.feature.PointFeature;
import org.openscales.core.layer.FeatureLayer;
import org.openscales.core.style.Style;
import org.openscales.geometry.Point;
import org.openscales.proj4as.ProjProjection;
import org.openscales.core.feature.CustomMarker;
import org.openscales.geometry.basetypes.Location;

[Bindable] private var map:Map = null;
private function initMap():void {
map = fxmap.map;
/**
*添加标注
*/
//创建一个功能层
var markers:FeatureLayer = new FeatureLayer("NameOfYourLayerWithMarkers");
//定义使用层的投影
markers.projection = new ProjProjection("EPSG:4326");
//地图标注显示的分辨率
markers.generateResolutions(19);
//定义一个默认样式
markers.style = Style.getDefaultPointStyle();

//add the first marker
//创建一个正确的坐标点 (需要与层的投影相同)
var marker:PointFeature = PointFeature.createPointFeature(new Location(-114.85680,45.75336));
markers.addFeature(marker);

//add a second marker
marker = PointFeature.createPointFeature(new Location(-94.85780,45.75336));
markers.addFeature(marker);

//add marker with different symbol, writing url address
markers.addFeature(CustomMarker.
createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png",
new Location(-101.85580,45.75336)));

//add the layer
map.addLayer(markers);
}
]]>
</fx:Script>

</s:Application>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值