0
我試圖讓Google地圖在我的項目中工作,但由於某種原因,當我嘗試搜索localhost/front訪問該頁面時,頁面上什麼也沒有顯示。地圖不顯示在Laravel
master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laramap</title>
</meta>
<link rel="stylesheet" href="{{asset('css/main.css')}}">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</link>
</head>
<body>
@yield('content')
<script crossorigin="anonymous" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" src="https://code.jquery.com/jquery-3.1.0.min.js">
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC4NNeHbNb1_nFhKnckNxMKpxXeQUecenM"
async defer></script>
<script src="={{asset('js/script.js')}}"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</body>
</html>
front.blade.php
@extends('layouts.master')
@section('content')
<div class="container">
<div id="map">
</div>
</div>
@endsection
的script.js
$(document).ready(function() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
scrollwheel: false,
zoom: 8
});
});
的main.css
#map{
heoght: 500px;
width: 600px;
margin: 0 auto;
}
web.php
Route::get('/', function() {
return view('welcome');
});
Auth::routes();
Route::any('/home', '[email protected]')->name('home');
Route::group(['as' => 'user.'],function() {
Route::get('/front',function() { return view('front');});
Route::get('/settings',['as'=> 'settings','uses'=> '[email protected]']);
Route::post('/settings',['as'=> 'settings','uses'=> '[email protected]']);
Route::any('/profile/{userId}',['as'=> 'profile','uses'=> '[email protected]']);
});
變化'heoght的末尾添加
&libraries=places
:500像素;''要高度:500px' – Ohgodwhy不過我不要收回任何東西 – Russkiy
你有沒有得到任何Javascript錯誤?在控制檯? –