Google-Maps Android:绘制复杂 GeoJson 多边形的问题
我有一个返回 GeoJson 多边形(时区)的网络服务,我正在尝试使用 GeoJsonLayer
在地图对象上的图层中绘制它们
我已经在 geojson.io 它看起来不错(底部的图像),但是当我将它添加到地图时,它没有被填充,并且一些额外的行出现在下面南,看起来它没有正确关闭多边形,这是我用来加载文件的代码(我目前在本地原始文件夹中)
val layer = GeoJsonLayer(mGoogleMap, R.raw.sample_timezones_response, requireContext())
layer.addLayerToMap()
val polygonStyle = GeoJsonPolygonStyle()
polygonStyle.fillColor = resources.getColor(R.color.color_main_green_200, null)
polygonStyle.zIndex = 10000f
layer.features.forEach { it1 ->
it1.polygonStyle = polygonStyle
}
编辑:原始的json文件不遵循右手规则,我用python lib修复了它:geojson-rewind, 这个是通过https://geojsonlint.com/
我也尝试更新到该库的最新版本(18.0.2) 并将渲染器更新为较新的渲染器,但显示方式相同。
I have a webservice that returns GeoJson polygons (timezones) and I'm trying to draw them in a layer over the map object using GeoJsonLayer
I already tested the GeoJson file in geojson.io and it looks fine (image at the bottom) but when I add it to the map its not being filled and some extra lines appear down south, it looks like its not closing the poly properly, this is the code I'm using to load the file (I have it locally in raw folder at the moment)
val layer = GeoJsonLayer(mGoogleMap, R.raw.sample_timezones_response, requireContext())
layer.addLayerToMap()
val polygonStyle = GeoJsonPolygonStyle()
polygonStyle.fillColor = resources.getColor(R.color.color_main_green_200, null)
polygonStyle.zIndex = 10000f
layer.features.forEach { it1 ->
it1.polygonStyle = polygonStyle
}
This is the json file I'm trying with.
EDIT: the original json file was not followinf the right-hand rule, I fixed it with python lib: geojson-rewind, this is the fixed version that passes the test in https://geojsonlint.com/
I tried also updating to the latest version of the library (18.0.2) and updating the renderer to the newer one but it displays in the same way.
This is how it looks on android:
This is how its supose to look, same json file in geojson.io:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
验证 geojson 时,出现错误:
https:/ /www.rfc-editor.org/rfc/rfc7946#section-3.1.6
When validating the geojson, I get the error:
https://www.rfc-editor.org/rfc/rfc7946#section-3.1.6