I'm having trouble getting AmMaps to execute a function when I click on a state. Here's my code. This line is not operating as I expect it to:
map.addListener("clickMapObject", function(event) {
When I shorten "clickMapObject" to just "click", the function works fine. But I need clickMapObject so the map will be able to tell me which state I've clicked on; if I use click it will only give me lat/long coordinates. What am I doing wrong?
Got a response back from AmCharts support:
Just to clarify, if the area/state/country does not have any actions attach to it upon click (zoom, url, description, etc.) it does not generate any click events.
In this case you need to explicitly make all such "inactive" areas clickable by either setting "selectable" property for each area individually or globally via AreasSettings:
http://docs.amcharts.com/3/javascriptmaps/MapArea#selectable
http://docs.amcharts.com/3/javascriptmaps/AreasSettings#selectable
The latter is probably more universal if you want all areas to generate click event:
map.areasSettings = { rollOverColor: "#009ce0" selectable: true };I hope it helps.
And it did help. Adding selectable: true to my map.areasSettings object did the trick!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With