Integrating Google Maps in vue.js

后端 未结 6 1239
情书的邮戳
情书的邮戳 2020-12-08 15:24

I\'ve been trying to initialize a Google map on my vue.js project while including the script :



        
6条回答
  •  青春惊慌失措
    2020-12-08 15:42

    Initial vue part after Using google map callback function.

    function initMap(){	
    	var app = new Vue({
    		el:"#app",
    		data:{
    			name:"Niklesh Raut",
    			map:"",
    			mapOptions:{}
    		},
    		mounted(){
    			this.initMap();
    		},
    		methods:{
    			initMap: function(){
    				this.mapOptions = {
    					center: new google.maps.LatLng(21.139808079490507, 79.07690763473511),
    					zoom: 10,
    					mapTypeId: 'roadmap'
    				}
    				this.map = new google.maps.Map(document.getElementById("map"), this.mapOptions);
    			}
    		}
    	});
    }
    .wrapper {
        display: flex;
        width: 100%;
        align-items: stretch;
    }
    #content {
        width: 100%;
        /*padding: 20px;*/
        min-height: 100vh;
        transition: all 0.3s;
    }
    .map{
        height: 100%;
        width:100%;
    }
    
    
    	
    	
    
    
    Name : {{name}}

    Jsfiddle Link

提交回复
热议问题