2

我创建了 amMap 来绘制区域,我想禁用工具提示并在特定状态下单击时添加信息窗口。我怎样才能做到这一点。

4

1 回答 1

5

如果要禁用工具提示,balloonText请在areasSettings.

"areasSettings": {
  "balloonText": ""
}

要在单击某个状态时显示描述,只需将“description”属性添加到该状态的区域定义:

"dataProvider": {
    "map": "usaLow",
    "getAreasFromMap": true,
    "areas": [{
      "id": "US-TX",
      "description": "Texas is a large state in the southern U.S. with deserts, pine forests and the Rio Grande, a river that forms its border with Mexico. In its biggest city, Houston, the Museum of Fine Arts houses works by well-known Impressionist and Renaissance painters, while Space Center Houston offers interactive displays engineered by NASA. Austin, the capital, is known for its eclectic music scene."
    }]
  }

请记住还包括 ammap.css,因为描述框是用 CSS 设置样式的。

这是一个工作演示:

var map = AmCharts.makeChart( "chartdiv", {
  "type": "map",
  "theme": "light",
  "dataProvider": {
    "map": "usaLow",
    "getAreasFromMap": true,
    "areas": [{
      "id": "US-TX",
      "description": "Texas is a large state in the southern U.S. with deserts, pine forests and the Rio Grande, a river that forms its border with Mexico. In its biggest city, Houston, the Museum of Fine Arts houses works by well-known Impressionist and Renaissance painters, while Space Center Houston offers interactive displays engineered by NASA. Austin, the capital, is known for its eclectic music scene."
    }]
  },
  "areasSettings": {
    "autoZoom": true,
    "balloonText": ""
  }
} );
#chartdiv {
  width: 100%;
  height: 500px;
}
<link href="http://www.amcharts.com/lib/3/ammap.css" media="all" rel="stylesheet" type="text/css" />
<script src="http://www.amcharts.com/lib/3/ammap.js"></script>
<script src="http://www.amcharts.com/lib/3/maps/js/usaLow.js"></script>
<script src="http://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>

于 2015-07-19T10:12:49.793 回答