我收到以下错误
解析错误:意外的标记运算符 «=»,预期的 punc «,» 第 159 行,第 26 列
这是我的代码
function fitBounds(type="all", shape=null) {
var bounds = new google.maps.LatLngBounds();
if ( type == "all" ){
if ((circles.length > 0) | (polygons.length > 0)){
$.each(circles, function(index, circle){
bounds.union(circle.getBounds());
});
$.each(polygons, function(index, polygon){
polygon.getPath().getArray().forEach(function(latLng){
bounds.extend(latLng);
});
});
}
}
else if ( (type == "single") && (shape != null) ) {
if (shape.type == google.maps.drawing.OverlayType.MARKER) {
marker_index = markers.indexOf(shape);
bounds.union(circles[marker_index].getBounds());
}
else {
shape.getPath().getArray().forEach(function(latLng){
bounds.extend(latLng);
});
}
}
if (bounds.isEmpty() != true)
{
map.fitBounds(bounds);
}
}
原文由 Harsha M V 发布,翻译遵循 CC BY-SA 4.0 许可协议
您正在尝试使用 默认参数,这是 JavaScript 的前沿功能, 但支持有限。
除非您打开 ES6 选项,否则 JS Lint 会拒绝它们。