1
I have a problem with this function that generates a latitude and longitude Polyline.
However whenever I execute the Laravel’s Seed it generates the following error:
php ErrorException : array_push() expects parameter 1 to be array,string given
The function I call within Seed is as follows:
public function gerarPolyline()
{
$fake = \Faker\Factory::create('pt_BR');
$polyline = ['latitude' =>'' , 'longitude' => '' ];
for($i =0; $i < 1000; $i++){
$latitude = $fake->latitude($min = -90, $max = 90);
$longitude = $fake->longitude($min = -180, $max = 180);
array_push($polyline['latitude'], $latitude);
array_push($polyline['longitude'],$longitude);
}
return $polyline;
}
Really that’s what happened,
ErrorException : Array to string conversion
, and giving dd($latitude), it is returned to me something like: 42.878878 or a random latitude, I do not understand why is not performing the push.– Betini O. Heleno