diff --git a/src/Objects/Geometry.php b/src/Objects/Geometry.php index 864b8a8..0ef92a2 100644 --- a/src/Objects/Geometry.php +++ b/src/Objects/Geometry.php @@ -155,7 +155,7 @@ public function toArray(): array /** * @throws JsonException */ - public function toFeatureCollectionJson(): string + public function toFeatureCollectionJson(array $properties = []): string { if (static::class === GeometryCollection::class) { /** @var GeometryCollection $this */ @@ -164,10 +164,10 @@ public function toFeatureCollectionJson(): string $geometries = collect([$this]); } - $features = $geometries->map(static function (self $geometry): array { + $features = $geometries->map(static function (self $geometry, $index) use ($properties) { return [ 'type' => 'Feature', - 'properties' => [], + 'properties' => $properties[$index] ?? [], 'geometry' => $geometry->toArray(), ]; });