0

如何像在 ListView 的 itemclick 中一样在标记单击时获取标记项位置?

好的,我得到了答案

@Override
public void onInfoWindowClick(Marker marker) {
    // TODO Auto-generated method stub
    System.out.println("onInfoWindowClick method calling and marker position is "+marker.getPosition());

    String title =marker.getTitle();

    for(int i=0;i<CommonUtilities.CoffeeShop_array_list.size();i++){
        String s =CommonUtilities.CoffeeShop_array_list.get(i).Title;

        if(title.equalsIgnoreCase(s)){
            **marker_position** = i;
            System.out.println("position of marker - "+marker_position);
        }
    }
}
4

2 回答 2

4

这可能会帮助你

                mGoogleMap.setOnInfoWindowClickListener(
                          new OnInfoWindowClickListener(){
                            @Override
                            public void onInfoWindowClick(Marker arg0) {

                                // TODO Auto-generated method stub
                                arg0.hideInfoWindow();
                                double dlat =arg0.getPosition().latitude;
                                double dlon =arg0.getPosition().longitude;
                                String slat = String.valueOf(dlat);
                                String slon = String.valueOf(dlon);
                            alert.showpickAlertDialog2(PlacesMapActivity.this,slat , slon, arg0.getSnippet());  
                            }
                          }
                        );
于 2013-08-06T10:04:27.380 回答
0

这是从标记获取位置的简短代码:-

LatLng myLatLng = new LatLng(myMarker.getPosition().latitude,myMarker.getPosition().longitude);

试试看。

于 2016-02-07T11:24:34.220 回答