<esri:CompositeSymbol id="composite"> <esri:symbols> <esri:SimpleMarkerSymbol id="tst" size="1" style="circle" color="0xFF0000" /> <esri:TextSymbol id="label" background="true" text="{labeltext.text}" color="0xFF0000" > <flash:TextFormat size="15" font="Verdana" bold="true" italic="false" underline="false" /> </esri:TextSymbol> </esri:symbols> </esri:CompositeSymbol> <esri:DrawTool id="myDrawToollabel" drawEnd="drawTool_drawEndHandlerlabel(event)" markerSymbol="{composite}" graphicsLayer="{myGraphicsLayerlabel}" map="{myMap}" />
<mx:VBox> <mx:HBox paddingTop="10"> <mx:Text color="#76410C" width="43" text="Label Text" paddingLeft="8"/> <mx:TextInput id="labeltext" width="130" maxChars="55" /> </mx:HBox> <mx:HBox paddingLeft="50" paddingBottom="8"> <mx:Button click="addtext()" label="Label Map" /> </mx:HBox> </mx:VBox>
private function addtext():void { myDrawToollabel.activate(DrawTool.MAPPOINT) } private function drawTool_drawEndHandlerlabel(event:DrawEvent):void { myDrawToollabel.deactivate() }
Solved! Go to Solution.
private function addtext():void { myMap.addEventListener(MapMouseEvent.MAP_CLICK, onClickFunction); } private function onClickFunction(event:MapMouseEvent):void { const mapPoint:MapPoint = event.mapPoint; mapPoint.spatialReference = new SpatialReference(102100); var myGraphicMarker:Graphic = new Graphic(mapPoint, new TextSymbol(labeltext.text,null,0x000000,1, true,0x000000,true,0xffffff,"middle",0,0,0)); //myGraphicMarker.toolTip = "Marker added with ActionScript"; pointGraphicsLayer.add(myGraphicMarker); pointGraphicsLayer.refresh(); }
<esri:Map> <esri:ArcGISTiledMapServiceLayer/> <esri:GraphicsLayer> <!-- Note: the TextSymbol defines the attribute to use as the text --> <esri:symbol> <esri:CompositeSymbol> <esri:SimpleMarkerSymbol color="0xFF0000" size="1" style="circle"/> <esri:TextSymbol background="true" color="0xFF0000" textAttribute="myLabelField"> <flash:TextFormat bold="true" font="Verdana" italic="false" size="15" underline="false"/> </esri:TextSymbol> </esri:CompositeSymbol> </esri:symbol> <esri:Graphic> <esri:geometry> <esri:WebMercatorMapPoint lon="-4.485556" lat="48.390834"/> </esri:geometry> <esri:attributes> <fx:Object myLabelField="Brest"/> </esri:attributes> </esri:Graphic> <esri:Graphic> <esri:geometry> <esri:WebMercatorMapPoint lon="-117.1825" lat="34.054722"/> </esri:geometry> <esri:attributes> <fx:Object myLabelField="Redlands"/> </esri:attributes> </esri:Graphic> </esri:GraphicsLayer> </esri:Map>
private function addtext():void { myMap.addEventListener(MapMouseEvent.MAP_CLICK, onClickFunction); } private function onClickFunction(event:MapMouseEvent):void { const mapPoint:MapPoint = event.mapPoint; mapPoint.spatialReference = new SpatialReference(102100); var myGraphicMarker:Graphic = new Graphic(mapPoint, new TextSymbol(labeltext.text,null,0x000000,1, true,0x000000,true,0xffffff,"middle",0,0,0)); //myGraphicMarker.toolTip = "Marker added with ActionScript"; pointGraphicsLayer.add(myGraphicMarker); pointGraphicsLayer.refresh(); }