際際滷

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

More Related Content

03 add markers

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