Android map v2-Get marker position on marker click

丶灬走出姿态 提交于 2019-12-10 12:17:55

问题


How to get marker item position on marker click just like in ListView's itemclick?

ok i got the answer

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

回答1:


This may help you

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



回答2:


Here is a short code for get location from marker:-

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

try it.



来源:https://stackoverflow.com/questions/18077040/android-map-v2-get-marker-position-on-marker-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!