@maplibre/maplibre-react-native 11.0.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,12 +10,9 @@ import com.facebook.react.uimanager.ViewManagerDelegate
|
|
|
10
10
|
import com.facebook.react.uimanager.annotations.ReactProp
|
|
11
11
|
import com.facebook.react.viewmanagers.MLRNGeoJSONSourceManagerDelegate
|
|
12
12
|
import com.facebook.react.viewmanagers.MLRNGeoJSONSourceManagerInterface
|
|
13
|
-
import org.json.JSONException
|
|
14
|
-
import org.json.JSONObject
|
|
15
13
|
import org.maplibre.android.style.expressions.Expression
|
|
16
14
|
import org.maplibre.reactnative.components.sources.MLRNSourceManager
|
|
17
15
|
import org.maplibre.reactnative.utils.ExpressionParser
|
|
18
|
-
import java.net.MalformedURLException
|
|
19
16
|
import java.net.URI
|
|
20
17
|
import java.util.AbstractMap
|
|
21
18
|
|
|
@@ -38,28 +35,20 @@ class MLRNGeoJSONSourceManager(
|
|
|
38
35
|
|
|
39
36
|
override fun createViewInstance(themedReactContext: ThemedReactContext): MLRNGeoJSONSource = MLRNGeoJSONSource(themedReactContext)
|
|
40
37
|
|
|
41
|
-
fun isJSONValid(test: String): Boolean {
|
|
42
|
-
try {
|
|
43
|
-
JSONObject(test)
|
|
44
|
-
} catch (_: JSONException) {
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
|
|
50
38
|
@ReactProp(name = "data")
|
|
51
39
|
override fun setData(
|
|
52
40
|
source: MLRNGeoJSONSource,
|
|
53
41
|
value: String?,
|
|
54
42
|
) {
|
|
55
43
|
if (value != null) {
|
|
56
|
-
|
|
44
|
+
val trimmed = value.trimStart()
|
|
45
|
+
if (trimmed.startsWith("{")) {
|
|
57
46
|
source.setGeoJson(value)
|
|
58
47
|
} else {
|
|
59
48
|
try {
|
|
60
49
|
source.setURI(URI(value))
|
|
61
|
-
} catch (error:
|
|
62
|
-
Log.w(LOG_TAG, error.localizedMessage)
|
|
50
|
+
} catch (error: Exception) {
|
|
51
|
+
Log.w(LOG_TAG, "Invalid GeoJSON data or URL: ${error.localizedMessage}")
|
|
63
52
|
}
|
|
64
53
|
}
|
|
65
54
|
}
|
package/package.json
CHANGED