Google maps 在Meteor中显示谷歌地图问题?
我需要知道如何在Meteor中显示google地图。我做了一个示例,如下所示 Html代码:Google maps 在Meteor中显示谷歌地图问题?,google-maps,meteor,Google Maps,Meteor,我需要知道如何在Meteor中显示google地图。我做了一个示例,如下所示 Html代码: <head> <title>Maps</title> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script> </head> <body> {{> map
<head>
<title>Maps</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script>
</head>
<body>
{{> maps }}
</body>
<template name="maps">
<div id="map-canvas"></div>
</template>
问题是当我运行代码时没有显示地图。我对此一无所知。所以请建议我如何处理
Lets put the map on a initialize function like this.
initMap = function(){
console.log("*** Map Start ********")
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
console.log("*** Map end ********")
}
//return map;
现在是渲染函数
Template.maps.rendered = function(){
Meteor.setTimeout(function(){
initMapa();
},2500)
}
还要确保您有这样的.css文件
#map-canvas {
width: 100%;
height: 300px;
}
它应该能工作,测试它,告诉我即使没有地图也能工作。那么我能做什么?@Ethaan
#map-canvas {
width: 100%;
height: 300px;
}