我正在使用 bootstrap
主题,但在添加 google map api
时遇到一些问题。 map 位于 javascript
文件中,如下所示:
google.maps.event.addDomListener(window, 'load', init);
function init() {
var mapOptions = {
zoom: 15,
scrollwheel: false,
center: new google.maps.LatLng(41.428005, -8.674701),
styles: [
{
...
var mapElement = document.getElementById('map');
var map = new google.maps.Map(mapElement, mapOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(41.428005, -8.674701),
map: map,
在 html 中只有这个:
<section class="map">
<div id="map"></div>
</section>
如何在此处添加 Api
键?
谢谢。
最佳答案
当您在网站上包含脚本时,Google Maps API 的 key 将作为查询参数包含在 URL 中。
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
关于javascript - 如何在 Google Maps JavaScript API 中设置 API key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39512512/