close

先寫一個內部類別

  class MyInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
        @Override
        public View getInfoWindow(Marker marker) {
            return null;
        }

        @Override
        public View getInfoContents(Marker marker) {
            // 依指定layout檔,建立地標訊息視窗View物件
            View infoWindow = getLayoutInflater().inflate(R.layout.markerlayout, null);
            // 顯示地標title
            TextView title = ((TextView) infoWindow.findViewById(R.id.txtTitle));
            title.setText(marker.getTitle());
            // 顯示地標snippet
            TextView snippet = ((TextView) infoWindow.findViewById(R.id.txtSnippet));
            snippet.setText(marker.getSnippet());
            return infoWindow;
        }
    }

在oncreat中定義完Map、地點、之類...後如果要呼叫自訂的marker就+下面這句

 mMap.setInfoWindowAdapter(new  MyInfoWindowAdapter());

arrow
arrow
    全站熱搜

    程式小試身手 發表在 痞客邦 留言(0) 人氣()