Navigation
· index
· OpenScales v1.2 documentation »
在阅读本节前请先阅读第二节第 2节 : 创建第一个地图.
</pre> <pre> <b>import</b> <b>org.openscales.geometry.basetypes.Location</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.Map</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.feature.CustomMarker</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.feature.PointFeature</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.layer.FeatureLayer</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.style.Style</b>;</pre> <pre> <b>import</b> <b>org.openscales.geometry.Point</b>;</pre> <pre> <b>import</b> <b>org.openscales.proj4as.ProjProjection</b>;</pre> <pre> </pre> <pre> [Bindable] <b>private</b> <b>var</b> map:Map = <b>null</b>;</pre> <pre> <b>private</b> <b>function </b>initMap():void {</pre> <pre> map = fxmap.map;</pre> <pre> <b>var</b> markers:FeatureLayer = <b>new</b> FeatureLayer("NameOfYourLayerWithMarkers");</pre> <pre> markers.projection = <b>new</b> ProjProjection("EPSG:4326");</pre> <pre> markers.generateResolutions(19);</pre> <pre> markers.style = Style.getDefaultPointStyle();</pre> <pre> </pre> <pre> <i>//add the first marker</i></pre> <pre> <b>var</b> marker:PointFeature = PointFeature.createPointFeature(<b>new</b> Location(4.85680,45.75336));</pre> <pre> markers.addFeature(marker);</pre> <pre> </pre> <pre> <i>//add a second marker</i></pre> <pre> marker = PointFeature.createPointFeature(<b>new</b> Location(4.85780,45.75336));</pre> <pre> markers.addFeature(marker);</pre> <pre> </pre> <pre> <i>//add marker with different symbol, writing url address</i></pre> <pre> markers.addFeature(CustomMarker.</pre> <pre> createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png",</pre> <pre> <b>new</b> Location(4.85580,45.75336)));</pre> <pre> </pre> <pre> <i>//add the layer</i></pre> <pre> map.addLayer(markers);</pre> <pre> }</pre> <pre>
mxml文件的as部分将在地图上创建一个标注.
创建一个简单的地图标注你需要以下准备:
</pre> <pre> <b>import</b> <b>org.openscales.core.Map</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.feature.PointFeature</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.layer.FeatureLayer</b>;</pre> <pre> <b>import</b> <b>org.openscales.core.style.Style</b>;</pre> <pre> <b>import</b> <b>org.openscales.geometry.Point</b>;</pre> <pre> <b>import</b> <b>org.openscales.proj4as.ProjProjection</b>;</pre> <pre> </pre> <pre> [Bindable] <b>private</b> <b>var</b> map:Map = <b>null</b>;</pre> <pre> <b>private</b> <b>function </b>initMap():void {</pre> <pre> map = fxmap.map;</pre> <pre> <b>var</b> markers:FeatureLayer = <b>new</b> FeatureLayer("NameOfYourLayerWithMarkers");</pre> <pre> markers.projection = <b>new</b> ProjProjection("EPSG:4326");</pre> <pre> markers.generateResolutions(19);</pre> <pre> markers.style = Style.getDefaultPointStyle();</pre> <pre> </pre> <pre> <b>var</b> marker:PointFeature=PointFeature.createPointFeature(<b>new</b> Location(4.85980,45.75336));</pre> <pre> markers.addFeature(marker);</pre> <pre> map.addLayer(markers);</pre> <pre> }</pre> <pre>
将以下两行增加到层代码前
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地图中了.
§ 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
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.