2014-01-29 14 views
0

我是新來的谷歌地圖V2,我需要從點1繪製一個矩形,以點2,具有自定義顏色和寬度,我試圖用折線,但所有的標籤(市姓名,國家名稱)仍然可見,所以我該怎麼做?Android的地圖繪製V2定製矩形

謝謝

這就是我試圖

mMapView.addPolyline(new PolylineOptions() 
.add(new LatLng(xx,xx), new LatLng(xx,xx)) 
.width(50) 
.color(Color.parseColor("#f4f3f0"))); 
+1

你只可以創建兩個點之間的連線。 – AndroidHacker

+0

我怎麼能做到這一點,我知道行是折線至極工作不正常 –

+0

還檢查了我的崗位在這裏.. http://stackoverflow.com/questions/20901141/how-to-draw-free-hand-多邊形在谷歌地圖-v2在Android/20901610#20901610和http://stackoverflow.com/questions/21034636/implementing-google-places-api/21036171#21036171 – AndroidHacker

回答

1

剛纔看了Documentation

GoogleMap map; 
// ... get a map. 
// Add a thin red line from London to New York. 
Polyline line = map.addPolyline(new PolylineOptions() 
    .add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0)) 
    .width(5) 
    .color(Color.RED)); 
+0

多段線不會隱藏城市名稱,它被繪製在它們下面 –

1

使用

public class My_Map extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.map_activity); 
    GoogleMap map = ((MapFragment) getFragmentManager() 
      .findFragmentById(R.id.map)).getMap(); 

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(
      new LatLng(-18.142, 178.431), 2)); 

    // Polylines are useful for marking paths and routes on the map. 
    map.addPolyline(new PolylineOptions().geodesic(true) 
      .add(new LatLng(-33.866, 151.195)) 
      .add(new LatLng(-18.142, 178.431)) 
      .add(new LatLng(21.291, -157.821)) 
      .add(new LatLng(37.423, -122.091)) 
    ); 
} 
} 

有關詳細信息只是檢查How to draw free hand polygon in Google map V2 in Android?