为什么我的标注只为它不是为别人打工的最后一点工作? [英] Why my callout only work for the last point it's not working for the others?

查看:170
本文介绍了为什么我的标注只为它不是为别人打工的最后一点工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建标注功能,它真的很容易的工作,没有任何中断,但是当我有多个点,最后点标注功能只工作别人没有工作,我不知道为什么我在谷歌搜索很多次,但我没有得到任何结果,低于code它是单点工作:

I already created callout function for single point it's really easy work without any interruption , but when I have multiple point the callout function work only for last point the others not working I have no idea why I searched in google many times but I didn't get any result, the below Code it's work for single point :

  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();
                    }

                }

            }
        });

以上code为onsingleTaplistener,code为updateContent功能:

the above code for onsingleTaplistener , code for updateContent function :

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);

}

和code为createCongent功能:

and code for createCongent function :

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;
}

这是我的工作,但是当我导入同一code时,我有它不工作,请我需要你对此有何评论多点,感谢您的帮助...

it was work for me but when I import the same code when I have multiple point it doesnt work, please I need you comment , thanks for any help...

推荐答案

此错误发生时,你有每个位置上的针各个图形层,确保所有引脚都处于同一平面层,
因为如果它适用于一个位置,这意味着,它的工作原理,
那么如果它仅适用于最后一个,它MEAST最后一个是在不同的图形
我希望它能帮助

This error happens when you have each Location Pin on individual graphic layers , make sure that all Pins are at the same graphic layer, because if it works for one location , it means , it works , then if it works only for the last one , it meast the last one is on the different graphic I hope it helps

这篇关于为什么我的标注只为它不是为别人打工的最后一点工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆