Re: [問題] Google map 資訊視窗置中

看板AndroidDev作者 (羽翼狼)時間8年前 (2017/02/19 23:10), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《firewind (羽翼狼)》之銘言: : 各位前輩好 : 我是個新手開發android : 想請問一下 : 我在開發googlemap時使用自訂的資訊視窗 : 在點擊marker時會自動跳出資訊視窗 : 但有時資訊視窗大小會超過Fragment 使有些資訊看不到 : 所以我參考了一些資料 : 想使用setOnMarkerListener : 點擊marker時讓map.camera往下移動到可以看到全部資訊 : 可是最終呈獻成果都是跳到指定位置後又自動將camera跑到marker位置 : 而且在fragment置中 : 想請問一下這個可以怎麼改 : 非常感謝 ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.40.39.84 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1487304235.A.607.html → roy870075: http://stackoverflow.com/questions/15925319/how-to- 02/18 14:21 → roy870075: disable-android-map-marker-click-auto-center 02/18 14:21 → roy870075: 忘記縮網址了...只要在onMarkListener裡面return true 02/18 14:23 → roy870075: 就不會自動移到中間了 你好 非常感謝你的幫忙 找到了這個方法 不過使用時卻有問題 自訂的資訊視窗產生不出來了 想再請你幫忙一下 非常感謝 private GoogleMap.InfoWindowAdapter myInfoWindow= new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { return null; } @Override public View getInfoContents(Marker marker) { V = getLayoutInflater().inflate(R.layout.map_item,null); ImageView icon = (ImageView) V.findViewById(R.id.imageView); TextView title = (TextView) V.findViewById(R.id.lbl_title); TextView lbl_price = (TextView) V.findViewById(R.id.lbl_price); TextView lbl_distance = (TextView) V.findViewById(R.id.lbl_distance); if ("m1".equals(marker.getId())){ SharedPreferences sh = getSharedPreferences("Nearbuy",0);//用SharedPreferences測試成功 String name = sh.getString("userac",""); icon.setImageResource(R.drawable.logo); title.setText(name); // price.setText(""); // distance.setText(""); }else{ title.setText(name); lbl_price.setText(price + "元"); lbl_distance.setText(distance + "公尺"); Bitmap bmp = BitmapFactory.decodeByteArray(b, 0, b.length); icon.setImageBitmap(bmp); } return V; } }; private GoogleMap.OnMarkerClickListener myMarkClickListener = new GoogleMap.OnMarkerClickListener() { boolean donotmovecameratocentermarker = true; public boolean onMarkerClick(Marker marker) { map2.moveCamera(CameraUpdateFactory.scrollBy(0,-1000)); map2.setInfoWindowAdapter(myInfoWindow); return donotmovecameratocentermarker; } }; private GoogleMap.OnInfoWindowClickListener myInfoWindowClickListener= new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { } }; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.175.177.1 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1487517010.A.48D.html

02/21 12:11, , 1F
看我上次給的網址的第一個解答,回傳true後需要手動控
02/21 12:11, 1F

02/21 12:11, , 2F
制顯示或隱藏InfoWindow,marker.showInfoWindow();和l
02/21 12:11, 2F

02/21 12:11, , 3F
astOpenned.hideInfoWindow();
02/21 12:11, 3F
文章代碼(AID): #1OgRLIID (AndroidDev)
文章代碼(AID): #1OgRLIID (AndroidDev)