谷歌地图API停止在Wordpress模板中工作
Google Maps API stopped working in Wordpress Template
所以我的Google Maps API正在工作,但现在不工作了。浏览谷歌API地图上的文档,我没有发现任何变化。我们使用的是Wordpress PHP模板中嵌入的地图,我检查的所有内容似乎都是正确的。有什么变化吗?
这是初始代码:
<section id="main">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBqnue6HpFD-HQvnk_cOKTQmqAzE6Xb9NQ"></script>
<script type="text/javascript" src="http://www.americanraceronline.com/wp-content/uploads/dev/markerwithlabel.js"></script>
<script type="application/javascript" >
var map;
var infoWindow;
function initialize() {
var myLatLng = new google.maps.LatLng(40.6,-95.665);
var myOptions = {
center: myLatLng,
scrollwheel: true,
navigationControl: false,
mapTypeControl: false,
scaleControl: true,
draggable: true,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.Whitewater,
styles:[/lots of styles here/]};
var poly;
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var marker1 = new MarkerWithLabel({
position: new google.maps.LatLng(40.27488643704891, -110.740234375),
draggable: false,
raiseOnDrag: false,
map: map,
labelContent: "WEST",
labelAnchor: new google.maps.Point(22, 2),
labelClass: "mylabels", // the CSS class for the label
labelStyle: {opacity: 1.0},
icon: {}
});
该页面的链接为:http://www.americanraceronline.com/distributors/
我错过了什么?
在浏览器控制台中:
您已多次在此页面上包含Google Maps API。这可能会导致意外错误。main.js:60yl
这不需要太多解释:您必须重复包含Google API
,检查您的包含是否只包含API引用一次。
也许是文件main.js,行:60
对于谷歌地图地图选项,需要zoom
(请参阅参考资料),例如
var myOptions = {
center: myLatLng,
scrollwheel: true,
navigationControl: false,
mapTypeControl: false,
scaleControl: true,
draggable: true,
disableDefaultUI: true,
zoom: 9,
styles:[/lots of styles here/]
};
例如,我为您的代码创建了一个简单的Fiddle,直到提供了缩放功能才开始工作。
相关文章:
- 如何使MailHandler.php在Wordpress中工作
- .load ajax无法正常工作whitin wordpress主题
- 更新Wordpress和我的平滑滚动停止工作
- JS错误导致WordPress插件无法工作
- Wordpress WooCommerce添加到购物车,无法在移动网站上工作
- 谷歌地图API停止在Wordpress模板中工作
- 正在尝试获取此代码'在wordpress页面中工作的功能
- onmouseover无法在wordpress中工作
- wordpress 4.1 javascript停止工作
- 让Ajax为Wordpress上的所有用户工作
- j查询同位素错误.停止在 Wordpress 中工作
- WordPress jQuery灯箱突然不工作
- 无法让我的下拉菜单在基于引导的 Wordpress 主题中工作
- 我的Wordpress网站上的所有jQuery脚本都无法正常工作
- 导致WordPress管理部分无法工作的滚动代码
- 让jQuery在Wordpress中工作时遇到麻烦
- 为什么AJAX $.post不能在wordpress中工作
- JavaScript异步无法工作Wordpress
- 窗口滚动功能无法工作wordpress
- jQuery菜单上的点击功能li锚- slideToggle不工作(WordPress)