Select to view content in your preferred language

InfoPopupWidget not popolate at first click

554
1
08-05-2011 12:23 AM
MicheleFocareta
Deactivated User
Hi,
i am the prloben when i first-click  on item generate infopopupwindows empty if i click another item the infopopup is correctly popolate...

if I use ESRI API 2.3.1 and SDK 4.1 there is the problem, but if i use ESRI API 2.2 i do not have problem.

The probability part of error code is:

......

var infoWindowRenderer:ClassFactory = new ClassFactory();
var infoWindowContentisplayObject;

if (event.currentTarget != null)
{
var recreate:Boolean = true;
var graphic:Graphic = Graphic(event.currentTarget);

if (map.infoWindow.content != null) {
recreate = !((graphic.attributes.type == SocialMediaType.Flickr && (map.infoWindow.content is Flickr_InfoWindowRenderer)) ||(graphic.attributes.type == SocialMediaType.YouTube && (map.infoWindow.content is YouTube_InfoWindowRenderer)));
}

if (recreate) {
if (graphic.attributes.type == SocialMediaType.Flickr) {
infoWindowRenderer = new ClassFactory(Flickr_InfoWindowRenderer);

}
else if (graphic.attributes.type == SocialMediaType.YouTube) {
infoWindowRenderer = new ClassFactory(YouTube_InfoWindowRenderer);
}

infoWindowContent = infoWindowRenderer.newInstance();
map.infoWindow.content = infoWindowContent as UIComponent;
map.infoWindow.closeButtonVisible = true;

}
map.infoWindow.data = graphic.attributes;
map.infoWindow.label = graphic.attributes.title;
map.infoWindow.show(map.toMapFromStage(event.stageX, event.stageY));
}
.....

is there a solution?  is a bug af API 2.3.1 or not?
Thanks
Tags (2)
0 Kudos
1 Reply
MicheleFocareta
Deactivated User
Hello, today I found a solution to my problem!!
In my mxml file i created a <fx:Component  className="Flickr_InfoWindowRenderer"> :


<fx:Component  className="Flickr_InfoWindowRenderer">
     <mx:VBox verticalGap="0" autoLayout="true">
  <fx:Script>
  <![CDATA[
   protected function ShowImage(event:MouseEvent):void
    {
    if (event.currentTarget is Image) {
  var imageUrl:String = (event.currentTarget as Image).source as String;
  var urlRequest:URLRequest = new URLRequest(imageUrl);
         navigateToURL(urlRequest, "_blank");
     }
    }
      ]]>
  </fx:Script>
<mx:Image source="{data.image}" click="ShowImage(event)" maintainAspectRatio="true" width="240" height="160" />
<mx:Label text="Autore: {data.owner}" paddingBottom="0" paddingTop="0" horizontalCenter="0" />

</mx:VBox>
</fx:Component>


When i complete my search i add each item to graphic layer:

......
for each (var flickr:FlickrItem in event.Results) {
      
    var x:Number = Number(flickr.point.x.toPrecision(8)) ;
    var y:Number = Number(flickr.point.y.toPrecision(8));
   myArrCoord.addItem({coordX:x,coordY:y});

var mapPoint:MapPoint = new MapPoint(x, y, new SpatialReference(102100));
       var newMapPoint:MapPoint =  WebMercatorUtil.geographicToWebMercator(mapPoint) as MapPoint;
      
graphic = new Graphic(WebMercatorUtil.geographicToWebMercator(mapPoint));

graphic.attributes = {"type": "Flickr", "title": flickr.title, "owner": flickr.ownerName, "image": flickr.imageUrl, "datetaken": flickr.dateTaken, "description":flickr.description};



graphic.addEventListener(MouseEvent.CLICK, SocialMediaGraphic_ClickHandler);
flickrGraphicsGeowalker.add(graphic);
}

.....

When i click to item on the map infowindows is empty!!

SOLUTION

1) Add id to fx:Component 

<fx:Component id="Flickr" className="Flickr_InfoWindowRenderer">
      .......


2)Assigne ad graphic the component id
......
graphic.infoWindowRenderer = Flickr;
.....

Thanks
Michele
0 Kudos