您可以将此代码
https://github.com/rarylson/geochart-geojson
与此 geojson
https://github.com/Dataninja/geo-shapes/blob/master/italy/provinces.geojson一起使用
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=<YOURKEY>"
</script>
<script type="text/javascript" src="https://cdn.rawgit.com/rarylson/geochart-geojson/master/build/geochart-geojson.min.js"></script>
<script type="text/javascript">
google.charts.load("current");
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {
// Create and populate a data table
var data = new google.visualization.DataTable();
data.addColumn("string", "City");
data.addColumn("number", "Value");
data.addRows([
["VERCELLI", 10],
["NOVARA", 5],
]);
// Instantiate our Geochart GeoJSON object
var vis = new geochart_geojson.GeoChart(document.getElementById("mydiv"));
// Set Geochart GeoJSON options
var options = {
mapsOptions: {
center: {lat: 42, lng: 12},
zoom:6
},
geoJson: "https://raw.githubusercontent.com/Dataninja/geo-shapes/master/italy/provinces.geojson",
geoJsonOptions: {
idPropertyName: "NOME_PRO"
}
};
// Draw our Geochart GeoJSON with the data we created locally
vis.draw(data, options);
}
</script>
</head>
<body>
<div id="mydiv" style="width: 900px; height: 560px;"></div>
</body>