Select to view content in your preferred language

create new infosymbol

882
7
09-14-2010 03:15 AM
yanli
by
Emerging Contributor
how do i create infosymbol with C#
   <esri:InfoSymbol id="infoSymbol1">
        <esri:infoRenderer>
            <mx:Component>
                <mx:VBox >
                    
                    <mx:Label  text="{data.myphone}"/>
                                    </mx:VBox>
            </mx:Component>
        </esri:infoRenderer>
    </esri:InfoSymbol>

private function addsymbol():void{
     var myGraphic:Graphic=new Graphic(new MapPoint                       (66669.794213,42498.544789));
                  myGraphic.symbol=infoSymbol1;
               myGraphic.attributes["myphone"]="123";
                        myGraphicsLayer.add(myGraphic);




what's the error here? can't see  the label in the symbol box
Tags (2)
0 Kudos
7 Replies
yanli
by
Emerging Contributor
nobody can help me?

the mxml code like this  is ok..

<esri:Graphic>
                <esri:geometry>
                    <esri:MapPoint x="61669.794213" y="45498.544789"/>
                </esri:geometry>
                <esri:attributes>
                    <mx:Object>
                   
                       <mx:myphone>riri</mx:myphone>
                          </mx:Object>
                </esri:attributes>
            </esri:Graphic>


but is write with AS code  following is error

private function addsymbol():void{
     var myGraphic:Graphic=new Graphic(new MapPoint(66669.794213,42498.544789));
                  myGraphic.symbol=infoSymbol1;
               myGraphic.attributes["myphone"]="123";//the error here!!!!!
                        myGraphicsLayer.add(myGraphic);


can you help me...  thank you
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Yan,

   I think you had us all scratching our heads with this part
how do i create infosymbol with C#


Now that we know you really mean ActionScript code and not C# it a little easier to answer your question.

Here is the proper syntax for your code:
private function addsymbol():void{
    var myGraphic:Graphic=new Graphic(new MapPoint(66669.794213,42498.544789),infoSymbol1,{myphone: "123"});
    myGraphicsLayer.add(myGraphic);
   } 
0 Kudos
yanli
by
Emerging Contributor
Thank you for your reply..it is ok
while i try the code like this is error

var myGraphic:Graphic=new Graphic(new MapPoint(66669.794213,42498.544789));          myGraphic.symbol=infoSymbol1;
     myGraphic.attributes=new ArrayCollection([
                                     {myphone: "123"}
                                          ]);                   
                        myGraphicsLayer.add(myGraphic);
                   
  

how do create a new myGraphic.attributes? thank  you
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Yan,

   The way that I suggested in the last post works perfectly but if you must build the attributes separately than here is how

var myGraphic:Graphic=new Graphic(new MapPoint(66669.794213,42498.544789)); 
myGraphic.symbol=infoSymbol1;
var attribs:Object = {myphone: "123"};
myGraphic.attributes=attribs;
myGraphicsLayer.add(myGraphic);
0 Kudos
yanli
by
Emerging Contributor
myGraphic.attributes can be a Arraycollection?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Yan,


  If you look at the documentation for a graphic object it is wanting an Object for the attributes property.

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/Graphic.html
0 Kudos
yanli
by
Emerging Contributor
thank you for your reply ..
while  i find the example of '   query result  as chart ' in
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html 

in which the myGraphic.attributes is definited as a  ArrayCollection

while i try definite the  myGraphic.attributes  like the example is error .
0 Kudos