lundi 30 avril 2018

Laravel + vue js and vue2-google-maps

So i'm having some trouble with this library , i think i set up everything correctly but my component is not rendering , i get just a blank page with no errors in the console . This is my code :

Map Component

  <template>
      <div >
        <gmap-map :center="{lat:1.38, lng:103.8}" :zoom="12">
          <gmap-marker :position="{lat:1.38, lng:103.8}">
          </gmap-marker>
          <gmap-info-window :position="{lat:1.38, lng:103.8}">
            Hello world!
          </gmap-info-window>
        </gmap-map>
      </div>
    </template></strike>



    <script>
      export default {

      }
    </script>

    <style>
      .map-container, .vue-map-container {
        display: flex;
        width: 100%;
      }
    </style>'

Main.js

require('./bootstrap');
import Vue from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
import VueRouter from 'vue-router';
import routes from './routes';

import * as  VueGoogleMaps from 'vue2-google-maps'

Vue.use(VueGoogleMaps, {
  load: {
    key: 'My_api_key',
    v: '3.31',
    libraries: 'places'
  }
})


Vue.use(VueRouter);
const router = new VueRouter({
    routes
});


window.Vue = require('vue');


Vue.component('navbar-component', require('./components/LayoutComponents/NavbarComponent.vue'));
Vue.component('home-component', require('./components/HomeComponent.vue'));
Vue.component('map-component', require('./components/MapComponent.vue'));
Vue.component('footer-component', require('./components/LayoutComponents/FooterComponent.vue'));
Vue.component('register-component', require('./components/AuthComponents/RegisterComponent.vue'));
Vue.component('login-component', require('./components/AuthComponents/LoginComponent.vue'));



const app = new Vue({
    el: '#app',
    router
});

The router handles everything correctly but for some reason it won't load the map component when i have the map related code in it , if i put some text there it will load everything correctly . I installed vue2-google-maps with npm , it shows up in the package.json file correctly . I'm very new to Vue in general so I did my best to be on point .



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire