IvoryGoogleMapBundle存在问题。我已经安装了它(在composer.json和AppKernel.php中添加了行,在config.yml中添加了配置但删除了class和helper_class参数)但是当我使用
时 {{ google_map_js(map) }}
{{ google_map_css(map) }}
{{ google_map_container(map) }}
在树枝上,只出现黑色矩形。
在页面来源中显示:
<script type="text/javascript">
map_5346b73f6f0f3024962917_container = {"map":null,"coordinates":{},"bounds":{},"points":{},"sizes":{},"circles":{},"encoded_polylines":{},"ground_overlays":{},"polygons":{},"polylines":{},"rectangles":{},"info_windows":{},"marker_images":{},"marker_shapes":{},"markers":{},"marker_cluster":null,"kml_layers":{},"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},"closable_info_windows":{},"functions":{"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }}};
map_5346b73f6f0f3024962917_container.coordinates.coordinate_5346b73f6eb8d631196403 = coordinate_5346b73f6eb8d631196403 = new google.maps.LatLng(0, 0, true);
map_5346b73f6f0f3024962917_container.map = map_5346b73f6f0f3024962917 = new google.maps.MapView(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3,"disableDefaultUI":true,"disableDoubleClickZoom":true});
map_5346b73f6f0f3024962917.setCenter(coordinate_5346b73f6eb8d631196403);
</script>
<style type="text/css">
#map_canvas{
width:300px;
height:300px;
border:1px solid #000;
background_color:#fff;
}
</style>
<div id="map_canvas" style="width:300px;height:300px;"></div>
IvoryGoogleMapBundle是否需要任何谷歌地图API密钥或类似内容?
答案 0 :(得分:0)
你必须在js之前渲染html,尝试:
{{ google_map_container(map) }}
{{ google_map_css(map) }}
{{ google_map_js(map) }}
关于第二个问题,是的,您需要包含Google的APIv3,并提供服务器API密钥。