2017-10-16 43 views
-1

我正在顯示列表和地圖。當我單擊單擊時將信息或名稱輸入Toast消息中,我完成了列表。但在地圖上,如果我點擊,片段中沒有顯示任何信息或任何數據記錄適當的命中數據(Asume店名)。這不僅以android and geo marker結尾,並且還鏈接Algolia命中。請幫助我,我受苦最後四天。如果當我點擊地圖標記,應該顯示片段中的商店名稱和其他詳細信息,地理位置圖與algolia

@Override 
     public void onMapReady(final GoogleMap googleMap) { 
      mMap = googleMap; 
      CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(new LatLng(12.670913552202967,78.6066235229373),20); 
      mMap.animateCamera(cu); 
    mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 
     @Override 
     public boolean onMarkerClick(Marker marker) { 
      View v =getLayoutInflater().inflate(R.layout.hits_item,null); 
      return false; 
     } 
    }); 
} 

回答

0

如何添加標記?爲了在點擊標記時顯示某些內容,您需要設置titlesnippet。 例如:

final MarkerOptions marker = new MarkerOptions(); 
    try { 
     marker.title(jsonObject.getString("name")); 
    } catch (JSONException e) {} 
    try { 
     final String location = jsonObject.getString("smart_location"); 
     final String price = jsonObject.getString("price_formatted"); 
     marker.snippet(price + " - " + location); 
    } catch (JSONException e) {} 
    try { 
     final Double latitude = jsonObject.getDouble("lat"); 
     final Double longitude= jsonObject.getDouble("lng"); 
     marker.position(new LatLng(latitude, longitude)); 
    } catch (JSONException e) {} 

    mMap.addMarker(marker); 
+0

非常感謝。 我在模型類中有相同的代碼(如在Android的示例項目格式)。我的疑問是當我點擊標記時將數據傳遞給下一個活動(如商店名稱或register_id)。我在哪裏使用意圖。 –

+0

這是一個不同的問題,你問[這裏](https://stackoverflow.com/questions/46744809/if-i-click-the-marker-then-move-to-next-activity-detail-of-the-店與-ALGOL)。我會在那裏回覆。 –

+0

好的,請幫助我。 –

相關問題