0
我試圖在用戶移動時在位置數據的地圖上繪製多邊形。我不希望多邊形之間有任何中斷。我需要下一個多邊形的一側連接到前一個多邊形的一側。我會怎麼做呢?我有迄今爲止所做的,但我不確定如何收集位置數據並使用之前的數據來連接多邊形。連接多邊形邊與位置數據
我使用:
onLocationChanged(Location location) {
currentLocation = (new LatLng(location.getLatitude(), location.getLongitude()));
if(previousLocation != null) {
polygonCornerBackLeftCorner = SphericalUtil.computeOffset(currentLocation, widthInMeters/2, location.getBearing() + 90);
polygonCornerBackRightCorner = SphericalUtil.computeOffset(currentLocation, widthInMeters/2, location.getBearing() + 90);
}
previousLocation = currentLocation
}
polygonGenerator() {
PolygonOptions polygon = new PolygonOptions().add(polygonCornerBackLeftCorner, polygonCornerBackRightCorner, polygonCornerFrontRight, polyCornerFrontLeft).fillColor(Color.YELLOW);
getMap().addPolygon(whatsquare);
}