I’m trying to create a map using JVectorMap that will put information to an #output div after the user clicks a given marker (for example, if the user clicks on a marker labeled Alaska, facts about Alaska pop up in the #output div). Elsewhere on here, I’ve seen this code example, which outputs the name of the label…
onMarkerLabelShow: function(event, label, code) {
$("#output").html("Some information about "+ label.html());
}
I’m trying to use a switch here…
onMarkerLabelShow: function(event, label, code) {
switch (label) {
case Alaska:
$("#output").html($("#alaska-facts");
[break;]
case North Carolina:
$("#output").html($("#nc-facts");
[break;]
default:
$("#output").html("Please select a job site");
[break;]
}
}
The map doesn’t display when I run this code, and I may be on the wrong track altogether. Any help?
A couple of issues:
labelis an object and will not match the simplecasestatements matching string values. You might want to evaluate againstlabel.text()caseshould be quoted strings (i.e."North Carolina", notNorth Carolina)break;should not be wrapped in[](you don’t want an array ofbreak, you want to break out of theswitch).)for the lines setting the.html()with jQuery ID selectorsCorrected example: