Google geocharts with coordinates?

I want to use gooch geochart with coordinates (longtitute, latitute). But I can not find any example on this topic. There are many examples with an example of a region and a city. But with the coordinates I can not find.

Please, sample code, link, tutorial anything else?

Thanks.

+4
source share
2 answers

As the documentation says:

Marker Location [Required] The first column is a specific address line (for example, "Pennsylvania 1600"). OR The first two columns are numeric, where the first column is latitude and the second column is longitude.

You need to define the first two columns of your dataset as numerical values ​​representing latitude and longitude.

+3
source

Here you can check an example:

google.load('visualization', '1', {'packages': ['geochart']}); google.setOnLoadCallback(drawVisualization); function drawVisualization() {var data = new google.visualization.DataTable(); data.addColumn('number', 'Lat'); data.addColumn('number', 'Long'); data.addColumn('number', 'Value'); data.addColumn({type:'string', role:'tooltip'}); data.addRows([[41.151636,-8.569336,0,'tooltip']]); data.addRows([[ 39.059575,-98.789062,0,'tooltip']]); var options = { colorAxis: {minValue: 0, maxValue: 0, colors: ['#6699CC']}, legend: 'none', backgroundColor: {fill:'transparent',stroke:'#FFF' ,strokeWidth:0 }, datalessRegionColor: '#f5f5f5', displayMode: 'markers', enableRegionInteractivity: 'true', resolution: 'countries', sizeAxis: {minValue: 1, maxValue:1,minSize:5, maxSize: 5}, region:'world', keepAspectRatio: true, width:400, height:300, tooltip: {textStyle: {color: '#444444'}} }; var chart = new google.visualization.GeoChart(document.getElementById('visualization')); chart.draw(data, options); } 
 <script src="https://www.google.com/jsapi?fake=.js"></script> <div id="visualization"></div> 

There are many ways to do this, this is just one.

 data.addColumn('number', 'Lat'); data.addColumn('number', 'Long'); data.addColumn('number', 'Value'); data.addColumn({type:'string', role:'tooltip'}); data.addRows([[41.151636,-8.569336,0,'tooltip']]); data.addRows([[ 39.059575,-98.789062,0,'tooltip']]); 
+10
source

All Articles