2015-05-26 82 views
0

如何爲每個標記添加標記,並且標記始終與標記一起?因爲地圖上有許多標記(車輛),因此爲標記添加一個標記,以便用戶不需要點擊標記並知道標記(車輛)的許可證號碼。如何在android Google Map中添加標記標記?

enter image description here

+0

嘗試添加該與標記一起的牌照。 – Prachi

+0

@Vera我用紅色標出的形狀是一個許可證標籤。 –

+0

然後添加一個佈局,它具有汽車的imagview作爲標記和licesnse標記。並將此佈局用作標記。製作自定義標記 – Prachi

回答

0

嘗試此,

marker.showInfoWindow(); 
+0

我希望標記始終可見並與標記一起顯示,用戶無需點擊標記。 –

0
Use the Marker Class 

,並且是指該鏈接https://developers.google.com/maps/documentation/android/marker

放置在地圖的表面上的特定點的圖標。標記圖標是針對設備的屏幕而非地圖表面繪製的;即由於地圖旋轉,傾斜或縮放而不一定會改變方位。

的標記具有以下屬性:

Anchor 

將放置在標記的經緯度位置的圖像上的點。默認爲圖像左側和圖像底部的50%。

Position 

標記在地圖上的位置的LatLng值。如果您想移動標記,您可以隨時更改此值。

標題

當用戶點擊該標記中顯示的有關信息窗口的文本字符串。您可以隨時更改此值。

Snippet 

顯示在標題下方的其他文字。您可以隨時更改此值。

Icon 

顯示標記的位圖。如果圖標未設置,則顯示默認圖標。您可以使用defaultMarker(float)指定默認圖標的替代顏色。創建標記後,您無法更改圖標。

Drag Status 

如果要允許用戶拖動標記,請將此屬性設置爲true。您可以隨時更改此值。默認值是true。

Visibility 

默認情況下,標記是可見的。要使標記不可見,請將此屬性設置爲false。您可以隨時更改此值。

GoogleMap map = ... // get a map. 
    // Add a marker at San Francisco. 
    Marker marker = map.addMarker(new MarkerOptions() 
     .position(new LatLng(37.7750, 122.4183)) 
     .title("San Francisco") 
     .snippet("Population: 776733")); 
+0

我已經在地圖上生成了標記,我需要的是添加標記和標記。 –

+0

這就是所謂的自定義信息窗口... –

+0

看到這個可愛的教程http://androidfreakers.blogspot.in/2013/08/display-custom-info-window-with.html –

0

試試這個: 添加類代碼

private class CustomInfoWindowAdapter implements InfoWindowAdapter, IServerResponse, ServerParameterList { 

    private View view; 
    private String _spotId = ""; 
    LinearLayout _mainlayout; 

    public CustomInfoWindowAdapter() { 
     view = getLayoutInflater().inflate(R.layout.custom_balloon_overlay, 
       null); 
    } 

    @Override 
    public View getInfoContents(Marker marker) { 

     if (CustomMap.this._marker != null 
       && CustomMap.this._marker.isInfoWindowShown()) { 
      CustomMap.this._marker.hideInfoWindow(); 
      CustomMap.this._marker.showInfoWindow(); 
     } 
     return null; 
    } 

    @Override 
    public View getInfoWindow(final Marker marker) { 
     CustomMap.this._marker = marker; 

     String url = null; 

     // setup our fields 
     _title = (TextView) view.findViewById(R.id.balloon_item_title); 
     _snippet = (TextView) view.findViewById(R.id.balloon_item_snippet); 
     _mainlayout=(LinearLayout)view.findViewById(R.id.balloon_main_layout); 


     // IMPLEMENTING BALLOON DETAILS 
     ImageButton details = (ImageButton) view 
       .findViewById(R.id.balloon_details); 


     /*_storeIdTextView = (TextView) parent 
       .findViewById(R.id.balloon_storeId_custom); 
     _storeIdTextView.setVisibility(View.GONE);*/ 

     if(marker.getTitle()!=null) 
     { 
      _title.setText(marker.getTitle()); 
     } 
     /* if(marker.getSnippet()!=null) 
    { 
     _snippet.setText(marker.getSnippet()); 
    }*/ 


     return view; 
    } 

    @Override 
    public void serverResponse(String response, int processid) { 
     // TODO Auto-generated method stub 
     System.out.println("Response Custom"+response); 


    } 


} 

其中custom_balloon_overlay是你的佈局

並在地圖上使用它像:

mapView.setInfoWindowAdapter(new CustomInfoWindowAdapter()); 
+0

如果工作請標記答案權利 – Prashant

相關問題