@cboxdk I don't believe you can load external scripts inside a Vue component's template (that's why when removing
May 2, 2016
5
Level 7
Issues with google maps / MapBox in vue component
As the topic states i have issues getting maps to work when it's inside a vue component. As an example i inserted a simple google map inside the home view like below. Not sure if this is a vuejs or spark thing, but i hope someone can push me in the right direction to solve it.
@extends('spark::layouts.app')
@section('content')
<home :user="user" inline-template>
<div class="container">
<!-- Application Dashboard -->
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Dashboard</div>
<div class="panel-body">
<div id="map" style="height: 400px; width: 100%"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=secretkey&callback=initMap"
async defer></script>
</div>
</div>
</div>
</div>
</div>
</home>
@endsection
If i remove the
@extends('spark::layouts.app')
@section('content')
<div class="container">
<!-- Application Dashboard -->
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Dashboard</div>
<div class="panel-body">
<div id="map" style="height: 400px; width: 100%"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=secretkey&callback=initMap"
async defer></script>
</div>
</div>
</div>
</div>
</div>
@endsection
Please or to participate in this conversation.