Select to view content in your preferred language

Hello all, Please help me to sort out this problem. I am trying to create popup for feature Layer but i am getting popup info null...

10577
5
Jump to solution
03-03-2015 07:59 PM
imritanshu
Regular Contributor

Hello all, Please help me to sort out this problem. I am trying to create popup for feature Layer but i am getting popup info null...

mapView.addLayer(new ArcGISFeatureLayer("","",""));

mapView.setOnSingleTapListener(new OnSingleTapListener() {

  private static final long serialVersionUID = 1L;

  @Override

  public void onSingleTap(float x, float y) {

  if(mapView.isLoaded())

  {

  popupContainer=new PopupContainer(mapView);

  popupDialog=null;

  int id=popupContainer.hashCode();

  Layer[]layers=mapView.getLayers();

  for(Layer layer:layers)

  {

  if(layer instanceof ArcGISFeatureLayer)

  {

  if(!layer.isInitialized() && !layer.isVisible())

  continue;

  ArcGISFeatureLayer fLayer=(ArcGISFeatureLayer)layer;

  if(fLayer.getPopupInfo(0)!=null)

  {

  new RunQueryFeatureLayerTask(x, y, 5,id).execute(fLayer);

  }

  }

  }

  }

  }

  });

0 Kudos
1 Solution

Accepted Solutions
MengyiGuo
Deactivated User

If I understand correctly, popupDialog is an object of Popup class. In your code, it was set to null and never added into the PopupContainer.

The ArcGISFeatureLayer class can create Popup as shown in the following sample code:

MapView map = ;

ArcGISFeatureLayer featureLayer = ;

Feature feature = ; ……

Popup popup = featureLayer.createPopup(map, 0, feature);

PopupContainer popupContainer = ; 

popupContainer.addPopup(popup); // add popup to popup container

View pop-ups—ArcGIS Runtime SDK for Android | ArcGIS for Developers

Popup UI Customization | ArcGIS for Developers

View solution in original post

5 Replies
MengyiGuo
Deactivated User

If I understand correctly, popupDialog is an object of Popup class. In your code, it was set to null and never added into the PopupContainer.

The ArcGISFeatureLayer class can create Popup as shown in the following sample code:

MapView map = ;

ArcGISFeatureLayer featureLayer = ;

Feature feature = ; ……

Popup popup = featureLayer.createPopup(map, 0, feature);

PopupContainer popupContainer = ; 

popupContainer.addPopup(popup); // add popup to popup container

View pop-ups—ArcGIS Runtime SDK for Android | ArcGIS for Developers

Popup UI Customization | ArcGIS for Developers

imritanshu
Regular Contributor

Hii Mengyi,

First of all thank you so much for your reply. Yes, You r right. and i have added it in popupcontainer in next class i.e. "RunQueryFeatureLayerTask(x, y, 5,id).execute(fLayer);".

But the problem is that it is not going to that class because of PopupInfo.

So my problem is "why i am getting featurelayer popupinfo null."

PS: I have added like you have shown this example. my popup came with no value (Blank).

0 Kudos
imritanshu
Regular Contributor

Problem solved. But i think there is a bug in ArcGISFeatureLayer..getPopupInfo() method..

MengyiGuo
Deactivated User

Sorry for the late reply and I'm glad your problem is solved. Would you like to tell me more about how you solved the problem and the bug you found?

0 Kudos
imritanshu
Regular Contributor

hii, first i want to tell you that  i am using ArcGIS android SDK 10.2.4. And the error that i am getting is featureLayer.getPopupInfo()  is null.

But the same code i am using for a webmap it is working correctly. but in my case i have manually added a feature layer on a tiled map.

.

Solution is to creating a new popup and add all value manually.

i.e.

Popup popup=new Popup(mapView, feature); instead of 

Popup popup=fLayer.createPopup(mapView, sublayerId, feature);

0 Kudos