如何禁用工具提示并在amMap中添加信息窗口?

时间:2015-07-17 19:29:24

标签: jquery amcharts ammap

我创建了amMap来绘制区域,我想禁用工具提示并在特定状态下点击添加infowindow。我怎么能这样做。

1 个答案:

答案 0 :(得分: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>