javascript - Plotting cities in a specific state using Google Geochart - Stack Overflow

I'm trying plot markers in a specific city using google Geochart when the region is set to that st

I'm trying plot markers in a specific city using google Geochart when the region is set to that state (so just that state is displayed, not the entire US). I can get the specific state to plot, but when I try to add a marker nothing displays.

Nothing displays when I try to put markers on cities

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ".dtd">
<html xmlns="">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
 google.load('visualization', '1.1', {packages: ['geochart']});

function drawMarkersMap() {
  var data = google.visualization.arrayToDataTable([
    ['City',  'Population', 'Area'],
    ['Los Angeles',     2761477,    1285.31]
  ]);

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
   geochart.draw(data, {width: 556, height: 347, region: 'US-CA', resolution: 'provinces'});
}


google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization"></div>
</body>
</html>

However, I'm able to get it to plot when I just do it by state. So, swapping out the functions for this, it works just fine

function drawVisualization() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Country');
  data.addColumn('number', 'Popularity');
  data.addRow(['US-CA', 1000]);

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
  geochart.draw(data, {width: 556, height: 347, region: 'US-CA', resolution: 'provinces'});
}

I'm trying plot markers in a specific city using google Geochart when the region is set to that state (so just that state is displayed, not the entire US). I can get the specific state to plot, but when I try to add a marker nothing displays.

Nothing displays when I try to put markers on cities

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src="http://www.google./jsapi"></script>
<script type="text/javascript">
 google.load('visualization', '1.1', {packages: ['geochart']});

function drawMarkersMap() {
  var data = google.visualization.arrayToDataTable([
    ['City',  'Population', 'Area'],
    ['Los Angeles',     2761477,    1285.31]
  ]);

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
   geochart.draw(data, {width: 556, height: 347, region: 'US-CA', resolution: 'provinces'});
}


google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization"></div>
</body>
</html>

However, I'm able to get it to plot when I just do it by state. So, swapping out the functions for this, it works just fine

function drawVisualization() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Country');
  data.addColumn('number', 'Popularity');
  data.addRow(['US-CA', 1000]);

  var geochart = new google.visualization.GeoChart(
      document.getElementById('visualization'));
  geochart.draw(data, {width: 556, height: 347, region: 'US-CA', resolution: 'provinces'});
}
Share Improve this question edited May 17, 2012 at 3:10 user1104854 asked May 17, 2012 at 1:31 user1104854user1104854 2,16714 gold badges53 silver badges75 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

I figured it out. I had to enable dataMode: 'Markers' in options

Province level maps (e.g., US-CA) is not supported by GeoMaps. Works in GeoChart. There is a feature request on the Google Visualization API bug reports and feature requests.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745452406a4628332.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信