I have been trying to debug this with no luck. I have a fall through switch case that seems to work as I watch the stack and it hits all breaks points I set (pretend that the type is polygon and I put a break put on all that should come up). I hit every one of those but it fails. So.. here is the first one that does work.
function create_map_element3(type,op,map){
var _op={};
defined(map) ?_op.map=map:null;
defined(op.clickable) ?_op.clickable=op.clickable:null;
defined(op.visible) ?_op.visible=op.visible:null;
defined(op.zIndex) ?_op.zIndex=op.zIndex:null;
switch(type){
case "polygon" :
defined(op.editable) ?_op.editable=op.editable:null;
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
return new google.maps.Polygon(_op);
break;
case "rectangle" :
defined(op.editable) ?_op.editable=op.editable:null;
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
return new google.maps.Rectangle(_op);
break;
case "circle" :
defined(op.editable) ?_op.editable=op.editable:null;
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
return new google.maps.Circle(_op);
break;
case "polyline" :
defined(op.editable) ?_op.editable=op.editable:null;
defined(op.strokeWeight) ?_op.strokeWeight=op.strokeWeight:null;
return new google.maps.Polyline(_op);
break;
case "marker" :
defined(op.animation) ?_op.animation=op.animation:null;
return new google.maps.Marker(_op);
break;
};
}
that works.. I get the google map element out just fine. Now with the change, and again when I debug I hit all break points _op object is filled and have it’s properties filled… but nothing…
function create_map_element(type,op,map){
var _op={};
defined(map) ?_op.map=map:null;
switch(type){
case "polygon": case "polyline" : case "rectangle" : case "circle" : case "marker" :
defined(op.clickable) ?_op.clickable=op.clickable:null;
defined(op.visible) ?_op.visible=op.visible:null;
defined(op.zIndex) ?_op.zIndex=op.zIndex:null;
case "polygon": case "polyline" : case "rectangle" : case "circle" :
defined(op.strokeColor) ?_op.strokeColor=op.strokeColor:null;
defined(op.strokeOpacity) ?_op.strokeOpacity=op.strokeOpacity:null;
defined(op.strokeWeight) ?_op.strokeWeight=op.strokeWeight:null;
case "polygon": case "rectangle" : case "circle" :
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
case "polygon": case "polyline" :
defined(op.geodesic) ?_op.geodesic=op.geodesic:null;
case "marker" :
defined(op.animation) ?_op.animation=op.animation:null;
case "polygon" :
return new google.maps.Polygon(_op);
break;
case "rectangle" :
return new google.maps.Rectangle(_op);
break;
case "circle" :
return new google.maps.Circle(_op);
break;
case "polyline" :
return new google.maps.Polyline(_op);
break;
case "marker" :
return new google.maps.Marker(_op);
break;
};
}
But when I set the break points on the retrun line it hits it and all looks right.. but.. nothing.. Anyone have an idea? Thank you – Jeremy
[EDIT]
Based on , um I don’t know who deleted their anwser but it was on the right track of the cause of the case swtich failing… here is an option I was trying to do with the same idea as above.
function create_map_element(type,op,map){
var _op={};
defined(map)?_op.map=map:null;
defined(op.clickable) ?_op.clickable=op.clickable:null;
defined(op.visible) ?_op.visible=op.visible:null;
defined(op.zIndex) ?_op.zIndex=op.zIndex:null;
if( ["polygon","polyline","rectangle","circle"].indexOf(type)!== -1 ){
defined(op.strokeColor) ?_op.strokeColor=op.strokeColor:null;
defined(op.strokeOpacity) ?_op.strokeOpacity=op.strokeOpacity:null;
defined(op.strokeWeight) ?_op.strokeWeight=op.strokeWeight:null;
}
if( ["polygon","rectangle","circle"].indexOf(type)!== -1 ){
defined(op.fillColor) ?_op.fillColor=op.fillColor:null;
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
}
if( ["polygon","polyline"].indexOf(type)!== -1 ){
defined(op.geodesic) ?_op.geodesic=op.geodesic:null;
}
if(type == "marker"){
defined(op.animation) ?_op.animation=op.animation:null;
defined(op.cursor) ?_op.cursor=op.cursor:null;
defined(op.draggable) ?_op.draggable=op.draggable:null;
defined(op.flat) ?_op.flat=op.flat:null;
defined(op.icon) ?_op.icon=op.icon:null;
defined(op.optimized) ?_op.optimized=op.optimized:null;
defined(op.position) ?_op.position=op.position:null;
defined(op.raiseOnDrag) ?_op.raiseOnDrag=op.raiseOnDrag:null;
defined(op.shadow) ?_op.shadow=op.shadow:null;
defined(op.shape) ?_op.shape=op.shape:null;
defined(op.title) ?_op.title=op.title:null;
}
switch(type){
case "polygon" :
return new google.maps.Polygon(_op);
break;
case "rectangle" :
return new google.maps.Rectangle(_op);
break;
case "circle" :
return new google.maps.Circle(_op);
break;
case "polyline" :
return new google.maps.Polyline(_op);
break;
case "marker" :
return new google.maps.Marker(_op);
break;
};
}
Now odly this doesn’t work too BUT .. it hits all break points correctly and when I inspect it, it seems well. It just doesn’t return the google map element.. again the top code block (function create_map_element3) does work..
Don’t know why the down votes, but it does seem that the answer is, No, you can’t fix it as the case will iterate thru everything at it asserts that it’s case is true from the group it was in.
IE:
MADE the later
TRUE even if the type is “polygon”
Simply running break points in the function under each case shows that you hit inside even when the case was already hit. If you remove one of the fall thru cases IE: take case “marker” : out then as expected it passes by as again the type is “polygon” so the case was false.
Odd but it is what it is. Better explanations welcomed and this was based on the occurence pointed out by Dr. Molle.