03 add markers

2,002 views
1,911 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,002
On SlideShare
0
From Embeds
0
Number of Embeds
184
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

03 add markers

  1. 1. Add markers using openscales 1.2<br />Tutorial 3<br />Marine Jourdain<br />
  2. 2. Prerequisites<br />This tutorial begins where ”Create Your First Map Using OpenScales” (tutorial 2) left off.<br />2<br />
  3. 3. What you obtain with this tutorial<br />3<br />
  4. 4. Action Script code to obtain the map<br />4<br /><fx:Script><br /> <![CDATA[<br />importorg.openscales.basetypes.Location;<br />importorg.openscales.core.Map;<br />importorg.openscales.core.feature.CustomMarker;<br />importorg.openscales.core.feature.PointFeature;<br />importorg.openscales.core.layer.FeatureLayer;<br />importorg.openscales.core.style.Style;<br />importorg.openscales.geometry.Point;<br />import org.openscales.proj4as.ProjProjection;<br /> [Bindable] privatevar map:Map = null;<br />privatefunctioninitMap():void {<br /> map = fxmap.map;<br />varmarkers:FeatureLayer = newFeatureLayer("NameOfYourLayerWithMarkers");<br />markers.projection = newProjProjection("EPSG:4326");<br />markers.generateResolutions(19);<br />markers.style = Style.getDefaultPointStyle();<br />//add the first marker<br />varmarker:PointFeature = PointFeature.createPointFeature(newLocation(4.85680,45.75336));<br />markers.addFeature(marker);<br />//add a second marker<br /> marker = PointFeature.createPointFeature(newLocation(4.85780,45.75336));<br />markers.addFeature(marker);<br />//add marker with different symbol, writing url address<br />markers.addFeature(CustomMarker.<br />createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png", <br />newLocation(4.85580,45.75336)));<br />//add the layer<br />map.addLayer(markers);<br /> }<br /> ]]><br /></fx:Script><br />
  5. 5. Add a default style marker (1)<br />A marker is created in the Action Script part of the mxml file.<br />To create a simple marker you need:<br />to create a feature layer<br />to define the system of projection used by the layer<br />to generate the resolutions at which the markers will be visible<br />to define the default style<br />to create a point with the correct coordinates (same projection as the layer)<br />5<br />
  6. 6. Add a default style marker (2)<br />The Action Script code becomes:<br /><fx:Script><br /> <![CDATA[<br />importorg.openscales.core.Map;<br />importorg.openscales.core.feature.PointFeature;<br />importorg.openscales.core.layer.FeatureLayer;<br />importorg.openscales.core.style.Style;<br />importorg.openscales.geometry.Point;<br />import org.openscales.proj4as.ProjProjection;<br /> [Bindable] privatevar map:Map = null;<br />privatefunctioninitMap():void {<br /> map = fxmap.map;<br />varmarkers:FeatureLayer = newFeatureLayer("NameOfYourLayerWithMarkers");<br />markers.projection = newProjProjection("EPSG:4326");<br />markers.generateResolutions(19);<br />markers.style = Style.getDefaultPointStyle();<br />varmarker:PointFeature=PointFeature.createPointFeature(new Location(4.85980,45.75336));<br />markers.addFeature(marker);<br />map.addLayer(markers);<br /> }<br /> ]]><br /></fx:Script><br />6<br />
  7. 7. Add another marker<br />Write these two lines before adding the layer ( )<br />map.addLayer(markers);<br />marker = PointFeature.createPointFeature(new Location(4.85980,45.75336));<br />markers.addFeature(marker);<br />7<br />
  8. 8. Add marker with custom symbol<br />Symbol from URL address:<br />Add this import next to the others:<br />Add the marker using the static CustomMarker.createUrlBasedMarker(url, point) before adding the layer ( ):<br />importorg.openscales.core.feature.CustomMarker;<br />markers.addFeature(CustomMarker.<br />createUrlBasedMarker("http://earth.google.com/intl/en_uk/outreach/images/add_placemark.png", <br /> new Location(4.85980,45.75336)));<br />8<br />map.addLayer(markers);<br />
  9. 9. Here you are<br />Right now, you’re able to add markers to your OpenScales maps.<br />Find sources: http://www.openscales.org/tutorials/<br />9<br />

×