I need to show property listings in google map. Presently my code is for showing listings but I have no idea how to display the coordinates of the database locations on the google map. I have some idea of the required controller :
my controller :
public function ListingsGoogle(){
$markers = Listing::select('autocomplete','latitude','longitude')->get();
$markers = $markers->map(function ($item, $key){
return [$item->autocomplete, $item->latitude, $item->longitude];
});
$listing = Listing::get();
$listingscount = Listing::count();
return view('frontend.listings_google', compact('listingscount','listing','markers'));
}
The javascript file provided by the template designer has the following section for showing locations :
var locations = [
// Locations
[ locationData('URL','images/company-logo-01.png',"Company Name",'Job Name', 'verified'), 37.788181, -122.461270, 5, ''],
[ locationData('URL','images/company-logo-02.png',"Company Name",'Job Name', 'not-verified'), 37.788181, -122.461270, 5, ''],
];
What will be the javascript code for displaying the multiple locations ? Is the controller ok ?