Select to view content in your preferred language

Use PopUpConfig when Zooming to Feature?

508
1
04-11-2012 08:32 AM
chuckfrank
Frequent Contributor
Hi All,

I am selecting a feature on a map via a querystring.  I have written code to zoom and center the map on a feature that is selected via a passed in id parameter.  I'd like to show an infoWindow for the feature that would be the same as if the user clicked on the feature.  I've configured "popupconfig" properties in the main config.xml.  I can see all of the attributes of the feature while I'm debugging.  Is there a way that I can feed in the popup config and not have to write a bunch of code to display the field names and values?  It seems like all of the main pieces are there.  I know the layer and have the attributes, but how can I use the popupconfig to populate the infoWindow?  Code is below, but I'd be willing to do this differently if there is a better way.  Thanks!

     function onResult(featureSet:FeatureSet, token:XMLList = null):void
     {
          try
          {
         
               var mp:MapPoint = featureSet.features[0].geometry;
         
               // set the map scale and center
               map.scale = 36112;
        map.centerAt(mp);
        
        var fs:FeatureSet = featureSet;

  // use the layername (layerproperties.name) as the title - HERE IS WHERE I'D LIKE TO USE THE POPUP CONFIGURATION TO POPULATE THIS !
         var popUpInfo:PopUpInfo = new PopUpInfo();
         popUpInfo.title = lp.name;
         popUpInfo.description = "Field Names and Values Go Here!"
        
         var popUpRenderer:PopUpRenderer = new PopUpRenderer();
  popUpRenderer.popUpInfo = popUpInfo;

                // show the infoWindow at the point
  map.infoWindow.content = popUpRenderer;
  map.infoWindow.closeButtonVisible = false;
  map.infoWindow.show(mp);
        
        }
 catch (error:Error)
 {
      Alert.show(error.message);
 }
} 

Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable
Hi Chuck,

You can build your description via string concatenation.  I take that your data object is lp. I have put some code below:


 var content:String;
 content = "Address: " + lp.address + "\n";
 content += "City: " + lp.city + "\n";
 content += "State: " + lp.State + "\n";
 content += "Zip: " + lp.Zip;

        // use the layername (layerproperties.name) as the title - HERE IS WHERE I'D LIKE TO USE THE POPUP CONFIGURATION TO POPULATE THIS !
 var popUpInfo:PopUpInfo = new PopUpInfo();
 popUpInfo.title = lp.name;
 popUpInfo.description = content
         
        


Just concatenate your data together via string and assign that to your popUpInfo.description as above. You can use a loop or any other method to build your string.  Hope this helps you.

Ray
0 Kudos