diff --git a/src/Circle.php b/src/Circle.php index 13d971b..00f74f8 100644 --- a/src/Circle.php +++ b/src/Circle.php @@ -117,11 +117,10 @@ public function draw(Image $image, MapData $mapData): Circle */ public function getBoundingBox(): array { - $distance = GeographicConverter::latLngToMeters($this->center, $this->edge); - $latLng1 = GeographicConverter::metersToLatLng($this->center, $distance, 0); - $latLng2 = GeographicConverter::metersToLatLng($this->center, $distance, 90); - $latLng3 = GeographicConverter::metersToLatLng($this->center, $distance, 180); - $latLng4 = GeographicConverter::metersToLatLng($this->center, $distance, 270); - return [new LatLng($latLng1->getLat(), $latLng4->getLng()), new LatLng($latLng3->getLat(), $latLng2->getLng())]; + $distance = GeographicConverter::latLngToMeters($this->center, $this->edge) * 1.4142; + return [ + GeographicConverter::metersToLatLng($this->center, $distance, 315), + GeographicConverter::metersToLatLng($this->center, $distance, 135) + ]; } } diff --git a/src/samples/sample3.php b/src/samples/sample3.php index 1c60d4a..171d2e6 100644 --- a/src/samples/sample3.php +++ b/src/samples/sample3.php @@ -20,24 +20,14 @@ ->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM) ->addMarker(new LatLng(44.351933, 2.568113)) ->addMarker(new LatLng(44.351510, 2.570020)) - ->addMarker(new LatLng(44.351873, 2.566250)) + ->addMarker(new LatLng(44.351073, 2.566480)) ) ->addDraw( - (new Circle( - new LatLng(44.351933, 2.568113), - 'FF0000', - 5, - 'FF0000CC' - )) + (new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC')) ->setEdgePoint(new LatLng(44.351510, 2.570020)) ) ->addDraw( - (new Circle( - new LatLng(44.351933, 2.568113), - 'FF0000', - 5, - 'FF0000CC' - )) + (new Circle(new LatLng(44.351933, 2.568113), 'FF0000', 5, 'FF0000CC')) ->setRadius(40) ) ->fitToDraws(10)