AnsweredAssumed Answered

Callout for a selected point

Question asked by gakuminkato on May 22, 2013
Latest reply on May 25, 2013 by gakuminkato
Hello,

I am trying to show Callout for a selected(queried by a single tap) point data (Map service).
I believe query part works fine, as I checked that attribute values of a point data are assigned to valuables.
That is, "myPopupInfo" has an expected value. However, nothing show up after that.

I am not sure whether "popupContent"(TextView) and "rat"(LinearLayout) are correct.

I would really appreciate if anybody helped me out...
Thank you in advance,
Gakumin

 @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.map_view);    //Set a default tap action as pop-up   Map_view.setOnSingleTapListener(new OnSingleTapListener() {    private static final long serialVersionUID = 1L;    public void onSingleTap(float x_v, float y_v) {     Point point = Map_view.toMapPoint(x_v, y_v);     // Tolerance: 20 pixel     Envelope env_v = new Envelope(point,20*Map_view.getResolution(), 20*Map_view.getResolution());      new setDefaultTapActions_popup(env_v, dmsl_v.getSpatialReference(), point).execute(".../MapServer/0");    }       });     }     //Query dynamic map service layer by QueryTask(Modified from "PopupInWebmapForViewing.java")  private class setDefaultTapActions_popup extends AsyncTask<String, Void, FeatureSet> {      private Envelope env_v;   private SpatialReference sr;   private Point point;      public setDefaultTapActions_popup(Envelope env_v, SpatialReference sr, Point point) {     super();    this.env_v = env_v;    this.sr = sr;    this.point = point;   }      @Override   protected FeatureSet doInBackground(String... params) {    //Set query parameters    Query query = new Query();    query.setInSpatialReference(sr);    query.setOutSpatialReference(sr);    query.setGeometry(env_v);    //For now, max number of returned features is 10.    query.setMaxFeatures(10);    query.setOutFields(new String[] { "*" });        QueryTask queryTask = new QueryTask(".../MapServer/0");        //Execute query task    try {     FeatureSet fs_view = queryTask.execute(query);     //Get an array of graphics of the query result FeatureSet     Graphic[] resultGraphic = fs_view.getGraphics();     View popupView = createPopupView(resultGraphic[0]);          Map_view.getCallout().show(point, popupView);     } catch (Exception e) {     // TODO Auto-generated catch block     e.printStackTrace();    }     // TODO Auto-generated method stub    return null;   }    private View createPopupView(Graphic graphic) {    //Employ "createReportView" of "MyWater" sample of ESRI    LinearLayout ret = new LinearLayout(context);    ret.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,      LayoutParams.WRAP_CONTENT));        Object attribute;        attribute = graphic.getAttributeValue("Type_Store");    String Type_Store = null;    if (attribute != null){     Type_Store = (String)attribute;    }        attribute = graphic.getAttributeValue("Name_Store");    String Name_Store = null;    if (attribute != null){     Name_Store = (String)attribute;    }        attribute = graphic.getAttributeValue("Open_Close");    String Open_Close = null;    if (attribute != null){     Open_Close = (String)attribute;    }        attribute = graphic.getAttributeValue("Service");    String Service = null;    if (attribute != null){     Service = (String)attribute;    }        attribute = graphic.getAttributeValue("AmountSup");    Integer AmountSup = 0;    if (attribute != null){     AmountSup = (Integer)attribute;    }        StringBuilder myPopupInfo = new StringBuilder();    myPopupInfo.append("Type of Store:\t" + Type_Store);    myPopupInfo.append("\nName of Store:\t" + Name_Store);    myPopupInfo.append("\nOpen or Close?:\t" + Open_Close);    myPopupInfo.append("\nService:\t" + Service);    myPopupInfo.append("\nAmount of Supply:\t" + AmountSup);        TextView popupContent = new TextView(context);    popupContent.setText(myPopupInfo.toString());    popupContent.setTextColor(Color.WHITE);    popupContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);    popupContent.setPadding(1, 0, 1, 0);    ret.addView(popupContent);        // TODO Auto-generated method stub    return ret;   }     } 

Outcomes