mapbox / mapbox-plugins-android

Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
https://www.mapbox.com/android-docs/plugins/overview/
BSD 2-Clause "Simplified" License
241 stars 119 forks source link

How i can change polygon fillColor when polygon clicked? #1132

Closed zohouri closed 4 years ago

zohouri commented 4 years ago

I tried this code to change polygon fillColor in onAnnotationClick, but its not working right! fillManager.addClickListener(new OnFillClickListener() { @Override public void onAnnotationClick(Fill fill) { fill.setFillColor("BE2109"); fillManager.update(fill); } }); before click: image after click (It should be red not gray): image

langsmith commented 4 years ago

"BE2109" isn't enough. You need # in front of the HEX code.

Try fill.setFillColor(Color.parseColor("#BE2109"));

fillManager.addClickListener(new OnFillClickListener() {
                @Override
                public boolean onAnnotationClick(Fill fill) {
                    fill.setFillColor(Color.parseColor("#BE2109"));
                    fillManager.update(fill);
                    return false;
                }
            });

ezgif com-resize