Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  157] [ 4]  / answers: 1 / hits: 17276  / 8 Years ago, thu, november 24, 2016, 12:00:00

i am getting the following error




Parse error: Unexpected token operator «=», expected punc «,» Line
159, column 26




This is my code



  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);
}
}

More From » jslint

 Answers
4

You are trying to use Default parameters, which are a bleeding edge feature of JavaScript with limited support.



JS Lint rejects them unless you turn on the ES6 option.


[#59935] Tuesday, November 22, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eden

Total Points: 730
Total Questions: 117
Total Answers: 117

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;