This was working fine until yesterday, when the Google geochart has stopped listening to me!
Width and height are being ignored, and the map has returned to a small version in the top right of it's full width div.
google.load('visualization', '1', {'packages': ['geomap']});
function drawMap() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Visits');
data.addColumn({type:'string', role:'tooltip', 'p': {'html': true}});
data.addRows(#{GuideEditController.getCitiesData()});
var options = {
sizeAxis: { minValue: 0, maxValue: 100 },
displayMode: 'markers',
colorAxis: {colors: ['#33ADFF', '#003D66']},
width : '100%',
height : '600px',
enableRegionInteractivity: false,
keepAspectRatio: true,
legend : 'none',
tooltip: {isHtml: true}
};
var container = document.getElementById('map_canvas');
var geomap = new google.visualization.GeoChart(container);
geomap.draw(data, options);
};
....
<div class="map" id='map_canvas'></div>
<script type='text/javascript'>
drawMap();
</script>
This DIV seems to be the culprit to me.. I've got no idea where it came from, but assume it's a Google thing.
The reason the call is made after the DIV is because the map is loaded on a tab that is loaded after the main page.
This was working fine yesterday...
It seems Google GeoChart ignores width and height options (although they mention them in https://developers.google.com/chart/interactive/docs/gallery/geochart).
I had a similar problem and this worked for me:
var options = {
sizeAxis: { minValue: 0, maxValue: 100 },
displayMode: 'markers',
colorAxis: {colors: ['#33ADFF', '#003D66']},
enableRegionInteractivity: false,
keepAspectRatio: true,
legend : 'none',
tooltip: {isHtml: true}
};
...
<div id="map_canvas" class="map" style="width: 100%; height: 600px;"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With