douzhenyu6533 2017-06-22 13:18
浏览 53

地图没有出现在Laravel

I'm trying to get google maps to work in my project ,but for some reason nothing shows up on the page when I try to search localhost/front to access that page .

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', 'HomeController@index')->name('home');

Route::group(['as' => 'user.'],function () {

    Route::get('/front',function () { return view('front');});
    Route::get('/settings',['as'=> 'settings','uses'=> 'ProfileController@viewSettings']);
    Route::post('/settings',['as'=> 'settings','uses'=> 'ProfileController@saveSettings']);
    Route::any('/profile/{userId}',['as'=> 'profile','uses'=> 'ProfileController@viewProfile']);

});

enter image description here

  • 写回答

1条回答 默认 最新

  • douchixu3686 2017-06-22 17:29
    关注

    I had to add &libraries=places at the end of the key

    <script src="https://maps.googleapis.com/maps/api/jskey=AIzaSyC4NNeHbNb1_nFhKnckNxMKpxXeQUecenM&libraries=places"  async defer></script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口