Android集成高德地图实现自定义Marker

配置好地图之后首先是添加Marker

MarkerOptions markerOption = new MarkerOptions();
                                markerOption.position(new LatLng(Double.parseDouble(lat), Double.parseDouble(lon));
                                markerOption.draggable(true);
                                //Double.parseDouble(lat);
                                markerOption.title(String.valueOf(i));

                                markerOption.icon(BitmapDescriptorFactory.fromView(getMyView()));

                                aMap.addMarker(markerOption);

如果不想用高德地图的布局,还可以自定义布局

markerOption.icon(BitmapDescriptorFactory.fromView(getMyView()));

其中getMyView就是自定义的布局

 //自定义高德标点
    protected View getMyView() {

        View view = getActivity().getLayoutInflater().inflate(R.layout.diandiantu, null);
       

        return view;

    }

下面是Marker的点击事件

aMap.setOnMarkerClickListener(new AMap.OnMarkerClickListener() {
                                @Override
                                public boolean onMarkerClick(Marker marker) {
                                    

                                    return true;
                                }
                            });