diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ae4d91137a..9f829790d71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ - [default] Fix possible crash at RunLoop::wake() ([#16255](https://github.com/mapbox/mapbox-gl-native/pull/16255)) +- [android] Update toGeoJSON in android_conversion.hpp [#16243](https://github.com/mapbox/mapbox-gl-native/pull/16243) + + Before this chage, `toGeoJSON` method in `android_conversion.hpp` can't convert Object(Map in android) to GeoJSON object. + + But `within` expression need to accept an Object and then convert to GeoJSON object, now `toGeoJSON` method can convert both string and Object to GeoJSON. + ## maps-v1.3.0 (2020.02-relvanillashake) ### 🐞 Bug fixes diff --git a/platform/android/src/style/android_conversion.hpp b/platform/android/src/style/android_conversion.hpp index dc0a0acb313..6f16804597c 100644 --- a/platform/android/src/style/android_conversion.hpp +++ b/platform/android/src/style/android_conversion.hpp @@ -110,11 +110,31 @@ class ConversionTraits { } static optional toGeoJSON(const mbgl::android::Value &value, Error &error) { - if (value.isNull() || !value.isString()) { + if (value.isNull()) { error = { "no json data found" }; return {}; } - return parseGeoJSON(value.toString(), error); + + if (value.isString()) { + return parseGeoJSON(value.toString(), error); + } + + if (value.isObject()) { + mbgl::android::Value keys = value.keyArray(); + std::size_t length = arrayLength(keys); + for (std::size_t i = 0; i < length; ++i) { + if (keys.get(i).toString() == "json") { + auto v = value.get("json"); + if (v.isString()) { + return parseGeoJSON(v.toString(), error); + } else { + break; + } + } + } + } + error = {"no json data found"}; + return {}; } };