this is much more javascript than Laravel, but your javascript syntax is wrong.
When your fragment is eventually evaluated, it becomes:
var props = [ coords = [ ..., ...], contents = [ ... ], coords = [ ..., ...], contents = [ ... ], ... // continues @foreach ($room) ];
which is the wrong javascript syntax. Please check the source after loading the page and see what it really is and what you can do to fix the syntax. What you really need is to get an array of such objects:
var props = [ { lat: '...', long: '...', title: '...' }, { lat: '...', long: '...', title: '...'}, ... ];
To get this, you would do:
var props = [ @foreach ($rooms as $room) { lat: "{{ $room->lat }}", lng: "{{ $room->lng }}", title: "{{ $room->title }}" }, @endforeach ];
Then you need to iterate over the array like this ...
for (i = 0; i < props; i++) { var prop = new google.maps.LatLng(props[i].lat, props[i].lng); var title = props[i].title; ...
heisian
source share