
I am trying to show both a map with coordinates and a table of data for a specific page and I am trying to add dropdowns to filter both the map and the table.
I was able to draw the map and table with no problems, but then I tried to use a dashboard for the first time. The table come up just fine, but the map will not show anymore. I set the view options to what I believe are the proper settings.
Here is my code:
<script type="text/javascript">
google.load('visualization', '1.0', {packages: ['controls']});
</script>
<script type="text/javascript">
google.setOnLoadCallback(drawVisualization);
function drawVisualization(){
<?php
//echo "var geoData = google.visualization.arrayToDataTable([['Lat', 'Lon', 'Value', 'Name','Date','Event'],";
echo "var geoData = new google.visualization.DataTable();";
echo"geoData.addColumn('number', 'Lat');";
echo"geoData.addColumn('number', 'Lon');";
echo"geoData.addColumn('string', 'Value');";
echo"geoData.addColumn('number', 'Name');";
echo"geoData.addColumn('string', 'Date');";
echo"geoData.addColumn('number', 'Event');";
for($f = 0; $f < $count; $f++)
{
$var0 = mysql_result($result2,$f,'xcoor');
$var1 = mysql_result($result2,$f,'ycoor');
$var2 = mysql_result($result2,$f,'hh_number');
$var3 = mysql_result($result2,$f,'icemr_site');
$var4 = mysql_result($result2,$f,'hh_type');
$var5 = mysql_result($result2,$f,'hh_number');
$var6 = mysql_result($result2,$f,'today');
$var7 = mysql_result($result2,$f,'event_id');
switch ($var3) {
case '1':
$var3 = "Choma";
break;
case '2':
$var3 = "Nchelenge";
break;
case '3':
$var3 = "Mutasa";
break;
default:
$var3 = "unknown";
}
switch ($var4) {
case '1':
$var4 = "Cross-Sectional";
break;
case '2':
$var4 = "Longitudinal";
break;
default:
$var3 = "unknown";
}
echo"geoData.addRow([".$var0.",".$var1.",'".$var2." - ".$var3." - ".$var4."',".$var5.",'".$var6."',".$var7."]);";
}
//echo"]);";?>
var eventPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'control1',
'options': {
'filterColumnLabel': 'Event',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
var namePicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'control2',
'options': {
'filterColumnLabel': 'Name',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
var table = new google.visualization.ChartWrapper({
'chartType': 'Table',
'containerId': 'table_div',
'options': {
'alternatingRowStyle': true,
'allowHtml': true,
'page': 'enable',
'pageSize': 15
}
});
var map = new google.visualization.ChartWrapper({
'chartType': 'Map',
'containerId': 'map_div',
'options': {
'mapType': 'normal',
'showTip': true,
'useMapTypeControl': true,
'enableScrollWheel': true
},
'view': {'columns': [ 0, 1, 2 ]}
});
var dashboard = new google.visualization.Dashboard(document.getElementById('dash_div'));
dashboard.bind(namePicker, map);
dashboard.bind(eventPicker, map);
dashboard.bind(namePicker, table);
dashboard.bind(eventPicker, table);
dashboard.draw(geoData);
}
</script>
<?php
echo"</head>";
echo"<div id=\"dash_div\" style=\"width:100%; height: 100%;\">";
echo"<table>";
echo"<tr><td><div id=\"control1\"></div><div id=\"control2\"></div></td></tr>";
echo"<tr><td><div id=\"map_div\" style=\"width:50%; height: 50%;\"></div></td></tr>";
echo"<tr><td ><div id=\"table_div\"></div></td></tr>";
echo"</table>";
echo"</div>";
echo"</html>";
?>
Thanks for any help, just not too sure what is wrong.