源和目标标记的信息窗口

时间:2016-07-25 10:35:13

标签: android google-maps

我在地图中有两个标记来源和目的地。我已经实现了地理代码API来提取地点和邮政编码。我完成了。我有信息窗口来显示它。当我点击原点它显示响应和目的地相同。我已经完成了这个级别,但一个问题当我执行原始URL时,它会正确显示响应。当我单击结束标记时,它执行目标URL。但是信息内容视图被覆盖,原始标记的内容也发生了变化。我想修复this.suggest一些解决方案..

btnFindPath.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendRequest();


        }
    });




private void sendRequest() {
    String origin = etOrigin.getText().toString();

    String destination = etDestination.getText().toString();
    url= "https://maps.googleapis.com/maps/api/geocode/json?address="+etOrigin.getText()+"AIzaSyDnwLF2-WfK8cVZt9OoDYJ9Y8kspXhEHfI";

    if (origin.isEmpty()) {
        Toast.makeText(this, "Please enter origin address!", Toast.LENGTH_SHORT).show();
        return;
    }
    if (destination.isEmpty()) {
        Toast.makeText(this, "Please enter destination address!", Toast.LENGTH_SHORT).show();
        return;
    }

    try {

        new DirectionFinder(this, origin, destination).execute();
        new GetLocationTask().execute();
    }   catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}
    void getrequest(){
        url= "https://maps.googleapis.com/maps/api/geocode/json?address="+etDestination.getText()+"AIzaSyDnwLF2-WfK8cVZt9OoDYJ9Y8kspXhEHfI";
        new GetLocationTask().execute();

    }





googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {



        // Use default InfoWindow frame

        public View getInfoWindow(Marker arg0) {



            return null;
        }

        // Defines the contents of the InfoWindow

        public View getInfoContents(Marker arg0) {


            // Getting view from the layout file info_window_layout
            View v = getLayoutInflater().inflate(R.layout.info_window, null);


           TextView tvLat = (TextView) v.findViewById(R.id.tv_lat);


            String ll="";
            HashMap<String,String> hm = new HashMap<String, String>();
            TextView type = (TextView) v.findViewById(R.id.tv_lat);
                for (int z=0;z<list1.size();z++) {
                    hm = list1.get(z);
                    ll = ll + hm.get("long_name");

                }




            // Returning the view containing InfoWindow contents
            return v;

        }
    });
}

0 个答案:

没有答案