您的位置:首页 > 运维架构

OpenScales入门教程 第3节 : 增加一个标注

2011-04-19 19:03 323 查看



Navigation
· index
· OpenScales v1.2 documentation »

第3节 : 增加一个标注

准备工作

在阅读本节前请先阅读第二节第 2节 : 创建第一个地图.

本节范例将展示为以下效果?




Action Script代码显示地图





    import org.openscales.geometry.basetypes.Location;


    import org.openscales.core.Map;


    import org.openscales.core.feature.CustomMarker;


    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;


 


    [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(4.85680,45.75336));


        markers.addFeature(marker);


 


        //add a second marker


        marker = PointFeature.createPointFeature(new Location(4.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(4.85580,45.75336)));


 


        //add the layer


        map.addLayer(markers);


    }


]]>




增加一个默认的标注样式

mxml文件的as部分将在地图上创建一个标注.

创建一个简单的地图标注你需要以下准备:

创建一个功能层

定义使用层的投影

地图标注显示的分辨率

定义一个默认样式

创建一个正确的坐标点 (需要与层的投影相同)





    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;


 


    [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();


 


        var marker:PointFeature=PointFeature.createPointFeature(new Location(4.85980,45.75336));


        markers.addFeature(marker);


        map.addLayer(markers);


    }


]]>




增加一个地图标示

将以下两行增加到层代码前

map.addLayer(markers);


marker = PointFeature.createPointFeature(new Location(4.85980,45.75336));


markers.addFeature(marker);


使用自定义图片显示地图标示





你可以通过一个URL增加一个标示图片:首先需要应用一下库文件:

import org.openscales.core.feature.CustomMarker;


然后在增加的层中,增加一个地图标示:

markers.addFeature(CustomMarker.createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png", new Location(4.85980,45.75336)));


小结

现在你就能够增加一个地图标注在Openscales地图中了.

Table Of Contents

Tutorial 3 : Add markers

§ Prerequisites

§ What do you obtain with this tutorial?

§ Action Script code to obtain the map

§ Add a default style marker

§ Add another marker

§ Add marker with custom symbol

§ Here you are

This Page

Show Source

Quick search

Enter search terms or a module, class or function name.

Navigation

· index

· OpenScales v1.2 documentation »

© Copyright 2010, openscales.org. Created using Sphinx 1.0.4.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: