1
我想在我走路/駕駛時(連接點逐點)繪製多段線,但它出來凌亂(Image link)。我讀了建議here並做了一些研究,我想出了下面的代碼來做到這一點:在谷歌地圖v2上沒有正確地填充多義線在android
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment supportMapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
googleMap = supportMapFragment.getMap();
googleMap.getUiSettings().setCompassEnabled(false);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setMyLocationEnabled(true);
}
我從initializeDraw開始()第一名:
private void initializeDraw(){
rectLine = new PolylineOptions().width(5).color(Color.RED);
newPolyline = googleMap.addPolyline(rectLine);
}
而且比我開始OnLocationListener(使用network_provider):
RTlocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, drawLocationOnMap);
的LocationListener的(從中我更新的點(緯度/經度和聚焦凸輪上的位置):
LocationListener drawLocationOnMap = new LocationListener() {
public void onLocationChanged(Location location) {
LatLng newPoint = new LatLng(location.getLatitude(), location.getLongitude());
points = newPolyline.getPoints();
points.add(newPoint);
newPolyline.setPoints(points);
CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude()))
.zoom(18)
.bearing(0)
.tilt(70)
.build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
};
};
結果: Image link
通過看上面的圖片,它看起來像一個「曲折」,即使我走了直線百米線。任何幫助,將不勝感激。
你有沒有最後定爲精度的條件<千米工作?我遇到同樣的問題,需要知道準確度參數應該用於精確折線繪製結果嗎? –