2013-08-02 2 views
0

사용자 옆에있는 레스토랑을 표시하기 위해 Android 애플리케이션을 만들려고합니다. Google지도 디스플레이가 있고 식당에 마커를 추가합니다. 사용자가 마커를 탭하면 정보가 표시됩니다. 레스토랑의 제목, 평점 및 아이콘이있는 경우 표시됩니다. 나는 Place search을 사용하고 있으며 각 레스토랑에 대한 정보를 얻습니다. 작동하지만 아이콘을 표시하려고 할 때 null이 표시됩니다.google place marker.title에 아이콘 표시

들으 그래서 당신은 할 수 없습니다, reaturant

private InputStream OpenHttpConnection(String urlString) 
     throws IOException 
     { 
      InputStream in = null; 
      int response = -1; 

      URL url = new URL(urlString); 
      URLConnection conn = url.openConnection(); 

      if (!(conn instanceof HttpURLConnection))      
       throw new IOException("Not an HTTP connection"); 

      try{ 
       HttpURLConnection httpConn = (HttpURLConnection) conn; 
       httpConn.setAllowUserInteraction(false); 
       httpConn.setInstanceFollowRedirects(true); 
       httpConn.setRequestMethod("GET"); 
       httpConn.connect(); 

       response = httpConn.getResponseCode();     
       if (response == HttpURLConnection.HTTP_OK) { 
        in = httpConn.getInputStream();         
       }      
      } 
      catch (Exception ex) 
      { 
       throw new IOException("Error connecting");    
      } 
      return in;  
     } 

private Bitmap DownloadImage(String URL) 
{   
    Bitmap bitmap = null; 
    InputStream in = null;   
    try { 
     in = OpenHttpConnection(URL); 
     bitmap = BitmapFactory.decodeStream(in); 
     in.close(); 
    } catch (IOException e1) { 
     // TODO Auto-generated catch block 
     e1.printStackTrace(); 
    } 
    return bitmap;     
} 

의 이미지를 얻으려고 노력 메신저와 그것을 .title이 인수로 문자열을 사용

//Getting icon 
      String iconURL = hmPlace.get("iconURL"); 
      Bitmap bitmap = DownloadImage(iconURL); 
markerOptions.title(name + " : " + bitmap); 

답변

0

MarkerOptions를 표시하는 코드입니다 거기에 비트 맵 파일을 추가하십시오.

마커를지도에 추가하려면 this tutorial을보세요. 이미지를 표시하려면 사용자 정의 InfoWindowAdapter을 사용하여 사용자 정의 InfoWindow를 설정해야합니다.