Select to view content in your preferred language

Size and content(String) of Callout

1746
1
Jump to solution
05-25-2013 05:39 PM
GakuminKato
Deactivated User
Hello,

I am trying to show Callout containing String value in it.
The problem is that Callout showing up is very small. Also, I cannot see any string values (please see the attached jpg)...
I have checked the following point with debugging.
     1."myPopupInfo" and "popupContent" have expecting string values.

Also, I have checked some other posts in this forum. They are very helpful for me to understand basic ideas of Callout. But I still could not figure out my own problem...
I may be either missing very basic but necessary components or doing stupid basic errors in my codes...

I would be very grateful if anybody helped me out. I have been stuck at this point since last night...
Thank you so much in advance,
Gakumin


Here is my java code. (Sorry, it is little long. But I wanted to include all blocks related to Callout.)
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, View> {      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 View 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]);    } catch (Exception e) {     // TODO Auto-generated catch block     e.printStackTrace();    }     // TODO Auto-generated method stub    return null;   }      @Override   protected void onPostExecute(View popupView) {    // TODO Auto-generated method stub    super.onPostExecute(popupView);    Callout callout = Map_view.getCallout();    callout.setStyle(R.xml.callout_style);    callout.getStyle().setMaxHeight(150);    callout.getStyle().setMaxWidth(150);    callout.setContent(popupView);    callout.show(point);   }    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);    View popupView = getLayoutInflater().inflate(      R.layout.callout_view2, null);    TextView popupContent = (TextView) popupView      .findViewById(R.id.callout_textview2);     popupContent.setText(myPopupInfo.toString());    popupContent.setTextColor(Color.WHITE);    popupContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);    popupContent.setPadding(1, 0, 1, 0);        return popupView;     //   ret.addView(popupContent);    // TODO Auto-generated method stub //   return ret;   }     } 


Here is my "callout_view2" layout xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <TextView         android:id="@+id/callout_textview2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"         android:layout_alignParentTop="true"         android:padding="2dp"         android:text="callout"         android:textAppearance="?android:attr/textAppearanceMedium"         android:textColor="#FF0000"         android:textSize="16sp" />  </RelativeLayout>


Here is my "callout_style" xml
<?xml version="1.0" encoding="utf-8"?> <resources     xmlns:android="http://schemas.android.com/apk/res/android">  <calloutViewStyle      titleTextColor="#000000"      titleTextSize = "10"      titleTextStyle = "0"      titleTextTypeFace = "0"   frameColor="#FFC7C7C7"   backgroundColor="#FF0A0A0A"   flat="true"   cornerCurve="10"      anchor="8"   style="app:@style/darkgray_layout"/> </resources>
0 Kudos
1 Solution

Accepted Solutions
GakuminKato
Deactivated User
Hi all,

I have found why I could not make this work.
This was not issue of size of Callout. It was my simple coding error...
I have not returned anything after query in doInBackground.
Here is the updated code.

I am still beginner level programmer... Sorry about this.
Gakumin

   //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]);
                          //Added this one
    return popupview;
   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }

View solution in original post

0 Kudos
1 Reply
GakuminKato
Deactivated User
Hi all,

I have found why I could not make this work.
This was not issue of size of Callout. It was my simple coding error...
I have not returned anything after query in doInBackground.
Here is the updated code.

I am still beginner level programmer... Sorry about this.
Gakumin

   //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]);
                          //Added this one
    return popupview;
   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
0 Kudos