【问题标题】:Why my callout only work for the last point it's not working for the others?为什么我的标注只适用于最后一点,它不适用于其他点?
【发布时间】:2014-11-29 18:40:07
【问题描述】:

我已经为单点创建了标注功能,它真的很容易工作而没有任何中断,但是当我有多个点时,标注功能仅适用于最后一点,其他点不起作用我不知道为什么我在谷歌搜索了很多次但我没有得到任何结果,下面的代码适用于单点:

  mMapView.setOnSingleTapListener(new OnSingleTapListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onSingleTap(float x, float y) {

                callout.hide();

                // Handles the tapping on Graphic

                int[] graphicIDs = graphicsLayer.getGraphicIDs(x, y, 25);
                if (graphicIDs != null && graphicIDs.length > 0) {
                    Graphic gr = graphicsLayer.getGraphic(graphicIDs[0]);

                    Point location = (Point) gr.getGeometry();

                    SpatialReference sp = SpatialReference
                            .create(SpatialReference.WKID_WGS84);
                    Point aux = (Point) GeometryEngine.project(location,
                            mMapView.getSpatialReference(), sp);

                    try {

                        DecimalFormat df = new DecimalFormat("00.000000");

                        String latitude = df.format(aux.getX());
                        String longtitude = df.format(aux.getY());

                        Double finallat = (Double) df.parse(latitude);
                        Double finallon = (Double) df.parse(longtitude);

                        Log.e("LLLLL", latitude + ": " + longtitude);

                        updateContent(
                                (String) gr.getAttributeValue("Rating"),
                                (String) gr.getAttributeValue("Title"),
                                (String) gr.getAttributeValue("Category"),
                                finallat, finallon);
                        callout.setOffset(0, -15);
                        callout.show(location, content);

                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (java.text.ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }

            }
        });

上面的 onsingleTaplistener 代码,updateContent 函数代码:

public void updateContent(String rating, String title, String cate,
        Double finallat, Double finallon) {
    if (content == null)
        return;

    Log.e("Double", finallat + ":" + finallon);

    Cursor cur = database.showInfo(finallat, finallon);

    if (cur.moveToFirst()) {

        name = cur.getString(0);
        cata = cur.getString(1);
        vic = cur.getString(2);

    }

    Log.e("Name", name + ":" + cata + ":" + vic);

    TextView txt = (TextView) content.findViewById(TITLE_ID);
    txt.setText(name);

    TextView txt1 = (TextView) content.findViewById(REVIEW_ID);
    txt1.setText(cata);

    TextView txt2 = (TextView) content.findViewById(CATE_ID);
    txt2.setText(vic);

}

createCongent 函数的代码:

public View createContent() {
    // create linear layout for the entire view

    View view = LayoutInflater.from(SingleLocation.this).inflate(
            R.layout.sqmi, null);

    TextView titleView = (TextView) view.findViewById(R.id.county_name);
    titleView.setId(TITLE_ID);
    titleView.setTextColor(Color.BLACK);

    TextView titleView1 = (TextView) view.findViewById(R.id.vic);
    titleView1.setId(REVIEW_ID);
    titleView1.setTextColor(Color.BLACK);

    TextView titleView2 = (TextView) view.findViewById(R.id.cate);
    titleView2.setId(CATE_ID);
    titleView2.setTextColor(Color.BLACK);


    view.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            Message.message(getApplicationContext(),"you clicked");

        }
    });

    return view;
}

这对我有用,但是当我导入相同的代码时,当我有多个点时它不起作用,请我需要您的评论,感谢您的帮助...

【问题讨论】:

    标签: android map arcgis


    【解决方案1】:

    您正在过去的图层之上添加一个图层。尝试声明一个图形图层并在其上添加所有几何形式。

    【讨论】:

      【解决方案2】:

      当您将每个位置图钉放在单独的图形图层上时会发生此错误,请确保所有图钉都在同一图形图层上, 因为如果它适用于一个位置,这意味着,它有效, 那么如果它只适用于最后一个,它意味着最后一个在不同的图形上 希望对你有帮助

      【讨论】:

      • 先生,是的,当我将所有引脚放在一层时,我已经为单层添加了每个引脚,它工作正常,很好的回答老兄
      【解决方案3】:

      您不能在地图上显示多个标注。标注始终是设计的单个实例。此外,由于屏幕很小,在智能手机上显示多个标注并不是一个好主意。 当您有多个几何图形时,您可以做的是显示一个显示实体列表的标注,并在地图上用不同的符号突出显示相关的几何图形。

      【讨论】:

      • 是的,你是对的,我不需要这个外观,我在屏幕上有很多点,当我点击其中一个点时,什么都不会发生,但最后一个有标注,其他没有
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多