You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google GeoCharts区域渐变地图上显示城市名称文本

需求:区域渐变地图叠加文本标注

需要在带区域渐变效果的地图上叠加显示城市/国家名称文本,即合并以下两张地图:区域渐变图、文本标注图。优先选择Google GeoCharts实现,也可接受其他工具。

区域渐变地图
文本标注地图

临时解决方案

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script type="text/javascript">
    google.charts.load('current', {
      'packages':['geochart'],
    });
    google.charts.setOnLoadCallback(drawChart);

    function drawChart() {
      var data = google.visualization.arrayToDataTable([
        ['Country', 'Population'],
        ['United States', 330000000],
        ['Germany', 83000000],
        ['France', 67000000]
      ]);

      var options = {
        displayMode: 'regions',
        resolution: 'countries',
        colorAxis: {colors: ['#ece7f2', '#d6604d']}
      };

      var chart = new google.visualization.GeoChart(document.getElementById('geo_chart'));
      chart.draw(data, options);
    }
  </script>
  <style>
    #geo_chart {
      position: relative;
      width: 100%;
      height: 600px;
      z-index: -1;
    }

    .country-label {
      position: absolute;
      font-size: 12px;
      font-weight: bold;
      color: #000;
      pointer-events: none;
      z-index: 999;
    }
  </style>
</head>
<body>
  <div id="geo_chart">
    <div class="country-label" style="top: 40%; left: 35%;">United States</div>
    <div class="country-label" style="top: 48%; left: 60%;">Germany</div>
    <div class="country-label" style="top: 52%; left: 55%;">France</div>
  </div>
</body>
</html>

内容的提问来源于stack exchange,提问作者Prem Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 23:09:57