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

clip_image002

Navigation

· index

· OpenScales v1.2 documentation »

第3节 : 增加一个标注

准备工作

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

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

clip_image004

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);
使用自定义图片显示地图标示

clip_image006

你可以通过一个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
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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值