如何提取从标记的列表的标记信息 [英] How to extract a marker info from a list of markers

查看:141
本文介绍了如何提取从标记的列表的标记信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code创建使用发送纬度,经度和记录一个列表的名称信息三个阵列在mapfragment标记列表。我的目标是获得发送到一个新的意图名称记录的点击信息窗口时。现在将所有标记数组的最后一个项目的recordname但我需要发送到每个标记的具体信息。任何想法?

 的String [] = arraylatitud arrlat.toArray(新的String [arrlat.size()]);
            的String [] = arraylongitud arrlon.toArray(新的String [arrlon.size()]);
            的String [] = arrayrecordname arrrecname.toArray(新的String [arrrecname.size()]);            的for(int i = 0; I< arrlon.size();我++){
                     mapa.addMarker(新的MarkerOptions()
                    .POSITION(新经纬度(Float.valueOf(arraylatitud [I]),Float.valueOf(arraylongitud [I])))
                    .title伪(Grabación:+ arrayrecordname [I])
                    是.snippet(Latitud:+ arraylatitud [I] +Longitud:+ arraylongitud [I]));                    文件名= arrayrecordname [I]            }            mapa.setOnInfoWindowClickListener(新OnInfoWindowClickListener(){                    公共无效onInfoWindowClick(标记标记){
                           意向意图=新意图(MapArea.this,StreamingArea.class);
                           intent.putExtra(variable_selection,filename.toString());
                           startActivity(意向);
                    }
            }


解决方案

我刚刚做了一个博客张贴这一点。
你可以找到它:
http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html

标记每得到了一个ID。

 标记M = mapa.addMarker(新的MarkerOptions()
                .POSITION(新经纬度(Float.valueOf(arraylatitud [I]),Float.valueOf(arraylongitud [I])))
                .title伪(Grabación:+ arrayrecordname [I])
                是.snippet(Latitud:+ arraylatitud [I] +Longitud:+ arraylongitud [I]));m.getId();

如果您存储ID,与信息一起您可以根据需要得到正确的信息回

 的GetMap()。setOnInfoWindowClickListener(新OnInfoWindowClickListener(){        公共无效onInfoWindowClick(标记标记){
            INT ID = marker.getId();
            意图I =新意图(MapArea.this.getActivity(),StreamingArea.class);
            //你的code到这里
            i.putExtra(....);            startActivity(ⅰ);        }
    });

I'm using the following code to create a list of markers in a mapfragment using three arrays that sends the information of latitude, longitude and name of one list of records. My objective is to get send to a new intent the name of the record when the info window is clicked. Now sends for all markers the recordname of the last item of the array but I need send the specific info to each marker. Any idea?

            String[] arraylatitud = arrlat.toArray(new String[arrlat.size()]);
            String[] arraylongitud = arrlon.toArray(new String[arrlon.size()]);
            String[] arrayrecordname = arrrecname.toArray(new String[arrrecname.size()]);

            for(int i=0; i<arrlon.size();i++){


                     mapa.addMarker(new MarkerOptions()
                    .position(new LatLng(Float.valueOf (arraylatitud[i]),Float.valueOf (arraylongitud[i])))
                    .title("Grabación:" + arrayrecordname[i])
                    .snippet("Latitud:" + arraylatitud[i] + "Longitud:" + arraylongitud[i]));

                    filename = arrayrecordname[i];

            } 

            mapa.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

                    public void onInfoWindowClick(Marker marker) {


                           Intent intent = new Intent(MapArea.this, StreamingArea.class);
                           intent.putExtra("variable_selection", filename.toString());
                           startActivity(intent);


                    }
            }

解决方案

I've just made a blog post on this. You can find it at: http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html

Every marker has got an Id.

Marker m = mapa.addMarker(new MarkerOptions()
                .position(new LatLng(Float.valueOf (arraylatitud[i]),Float.valueOf (arraylongitud[i])))
                .title("Grabación:" + arrayrecordname[i])
                .snippet("Latitud:" + arraylatitud[i] + "Longitud:" + arraylongitud[i]));

m.getId();

if you store that id, along with the information you need you can get the right info back

getMap().setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        public void onInfoWindowClick(Marker marker) {
            int id = marker.getId();
            Intent i = new Intent(MapArea.this.getActivity(), StreamingArea.class);
            //your code goes here
            i.putExtra(....);

            startActivity(i);

        }
    });

这篇关于如何提取从标记的列表的标记信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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