【发布时间】:2020-11-03 14:36:44
【问题描述】:
我用 geojson.io 创建了 GeoJson:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"stroke": "#555555",
"stroke-width": 1,
"stroke-opacity": 1,
"fill": "#cc1414",
"fill-opacity": 0.5
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
38.91359567642212,
47.25578268604025
],
[
38.91415894031525,
47.25578268604025
],
[
38.91415894031525,
47.25588827416263
],
[
38.91359567642212,
47.25588827416263
],
[
38.91359567642212,
47.25578268604025
]
]
]
}
}
]
}
属性中有填充颜色:
"properties": {
"stroke": "#555555",
"stroke-width": 1,
"stroke-opacity": 1,
"fill": "#cc1414",
"fill-opacity": 0.5
}
然后我将它从 String 转换为 JSONObject,如下所示:JSONObject(geoJsonString),这就是我将图层应用于地图的方式:
fun drawPolygons(jsonObj: JSONObject) {
map?.let { map ->
val layer = GeoJsonLayer(map, jsonObj)
layer.addLayerToMap()
}
}
但谷歌地图完全忽略了所有属性。没有填充颜色,没有描边宽度。我需要从geojson字符串中全部应用它,而不需要代码。怎么做?
【问题讨论】:
标签: android google-maps kotlin geojson