Callout problem

791
1
11-13-2013 05:23 PM
JasonAllen
New Contributor
I have a .geodatabase from which I am creating FeatureLayers. I am trying to display a callout for the FeatureLayers. The callout works fine for polygons, however when I singleTap a point or polyline feature the callout shows and then hides. ??

  map.setOnSingleTapListener(new OnSingleTapListener() {
   private static final long serialVersionUID = 1L;

   public void onSingleTap(float x, float y) {    
    if (!map.isLoaded()) {
     return;
    }
    
    for (FeatureLayer featureLayer : gdbFeatureTableList) {
     long [] selFeatures = featureLayer.getFeatureIDs(x, y, 10, 10);
     
     if (selFeatures != null && selFeatures.length > 0) {      
      long targetID = selFeatures[0];
      Feature feature = featureLayer.getFeature(targetID);
      Map<String, Object> attributesMap = feature.getAttributes();
      
      StringBuilder sb = new StringBuilder();
      for (Entry<String, Object> att : attributesMap.entrySet()) {       
       if (!att.getKey().equalsIgnoreCase("GlobalID") && !att.getValue().toString().trim().equalsIgnoreCase("")) {
        sb.append(att.getKey() + ": " + att.getValue().toString() + "\n");
       }       
      }
      
      String attributes = sb.toString();
      callout.animatedShow(map.toMapPoint(new Point(x, y)), loadView(attributes));
     }
     
     else if (callout != null && callout.isShowing()) {
      callout.animatedHide();
     }
    }
   }
  });


I usually miss the simple things... If you can see one, please let me know..
0 Kudos
1 Reply
JasonAllen
New Contributor
I have fixed the original issue. See below.

  map.setOnSingleTapListener(new OnSingleTapListener() {
   private static final long serialVersionUID = 1L;

   public void onSingleTap(float x, float y) {    
    if (!map.isLoaded()) {
     return;
    }
    
    for (FeatureLayer featureLayer : gdbFeatureTableList) {
     if (featureLayer.getFeatureIDs(x, y, 10, 10).length == 0) {
      // Do nothing
     }
     else {
      long [] selFeatures = featureLayer.getFeatureIDs(x, y, 10, 10);
     
      if (selFeatures != null && selFeatures.length > 0) {      
       long targetID = selFeatures[0];
       Feature feature = featureLayer.getFeature(targetID);
       Map<String, Object> attributesMap = feature.getAttributes();
       
       StringBuilder sb = new StringBuilder();
       for (Entry<String, Object> att : attributesMap.entrySet()) {
        if (!att.getKey().equalsIgnoreCase("GlobalID") && !att.getValue().toString().trim().equalsIgnoreCase("")) {
         sb.append(att.getKey() + ": " + att.getValue().toString() + "\n");
        }       
       }
       
       String attributes = sb.toString();
       callout.animatedShow(map.toMapPoint(new Point(x, y)), loadView(attributes));
      }
     }
    }
   }
  });


Like I said, It's the simple things that get me...

I now have a different issue. One of my FeatureLayers has many attributes. Not all of these attributes are being shown in the Callout. Is there a character or string max limit for the Callout?
0 Kudos