Try to show Google Map through blade.php file using javascript , when i route show blank page in browser . here is Controller code
class ItemsController extends Controller {
public function map(){
$items = Item::all();
return view('items.map',compact('items'));
}
}
And blade.php Code
@extends('app')
@section('content')
<div class="container">
<div class="row">
<div id="map-canvas"></div>
</div>
</div>
<script type="text/javascript">
var mapOptions ={
zoom :4,
center:new google.maps.LatLng({{$items[0]->location}})
}
var map = new google.maps.Map(document.getElementById("map-canvas"),mapOptions);;
@foreach($items as $item)
var marker{{$item->id}}=new google.maps.Marker({
position: new google.maps.LatLng({{$item->location}}),
map:map,
title:"{{$item->title}}"
});
@endforeach
</script>
Database Migration file is here :
public function up()
{
Schema::create('items', function(Blueprint $table)
{
$table->increments('id');
$table->string('title');
$table->timestamps();
});
DB::statement('ALTER TABLE items ADD location POINT');
}