this exampleのようなマップで作業していましたが、クリックすると複数の国を同時に選択できます。これを世界地図に追加しましたが、一度クリックすると国が青くなり、2回クリックすると赤くなり、3回目にクリックすると選択されなくなります。私が現在働いていることで、国が2回クリックされると、別の国を移動した後に赤く表示されます。選択した色を正しく設定していませんか?私はドキュメントといくつかの例を見てきましたが、私は解決策を見つけることができませんでした。どんな助けでも大歓迎です。ここに私がこれまで持っているものがあります。クリックしてエリアの選択した色を切り替えます。
var map = AmCharts.makeChart("chartdiv", {
"type": "map",
"theme": "light",
"projection": "miller",
"dataProvider": {
"map": "worldLow",
"getAreasFromMap": true
},
"areasSettings": {
"autoZoom": false,
"color": "#CDCDCD",
"selectedColor": "#5EB7DE",
"selectable": true
},
"listeners": [{
"event": "clickMapObject",
"method": function(event) {
// deselect the area by assigning all of the dataProvider as selected object
map.selectedObject = map.dataProvider;
if (event.mapObject.showAsSelected == false || typeof event.mapObject.showAsSelected == 'undefined') {
event.mapObject.showAsSelected = true;
} else if (event.mapObject.showAsSelected == true && event.mapObject.selectedColorReal == "#5EB7DE") {
event.mapObject.selectedColorReal = "#CC0000";
} else {
event.mapObject.showAsSelected = false;
event.mapObject.selectedColorReal = "#5EB7DE"
map.returnInitialColor(event.mapObject);
}
}
}],
"export": {
"enabled": true,
"position": "bottom-right"
}
});
#chartdiv {
width: 100%;
height: 500px;
}
<script src="https://www.amcharts.com/lib/3/ammap.js"></script>
<script src="https://www.amcharts.com/lib/3/maps/js/worldLow.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<div id="chartdiv"></div>