AnyChart-Android icon indicating copy to clipboard operation
AnyChart-Android copied to clipboard

Choropleth Map listener issue

Open margin555 opened this issue 5 years ago • 1 comments

In Choropleth Map how can I detect the clicked state (states in the US) and also how can I enable multiple states click

margin555 avatar Jul 24 '19 09:07 margin555

@margin555 Unfortunately, the current version of the library doesn't provide a listener on multiple selections, only on a single click/select. The snippet below describes how to achieve that (the map file is placed in app assets, getData() returns the series data:

        Map map = AnyChart.map();

        map.geoData("anychart.maps.united_states_of_america");

        Choropleth series = map.choropleth(getData());

        map.setOnClickListener(new ListenersInterface.OnClickListener(new String[]{"id", "name", "value"}) {
            @Override
            public void onClick(Event event) {
                event.getData().get("id");
                event.getData().get("name");
                event.getData().get("value");

                Log.d("MapListener", event.getData().get("id"));
            }
        });
        
        anyChartView.addScript("file:///android_asset/united_states_of_america.js");
        anyChartView.addScript("file:///android_asset/proj4.js");
        anyChartView.setChart(map);

Shestac92 avatar Jul 26 '19 09:07 Shestac92