如何在GeoJSON图层中用多余的线条填充颜色多边形?

问题描述 投票:0回答:1

我是android中的GeoJson图层的初学者。我想在GeoJson图层上绘制填充一些颜色的多边形。问题是我无法在GeoJson图层上用多余的线条填充多边形的颜色。

这是我的代码。

 heatMapLayer = GeoJsonLayer(map,  [2]JSONObject(Gson().toJson(featureCollection)))
        heatMapLayer?.features?.forEach {
            var colorIndex = it.getProperty("temp").toDouble().toInt()
            if (colorIndex < -10) {
                colorIndex = -10
            }
            if (colorIndex > 40) {
                colorIndex = 40
            }
            val polygonStyle = GeoJsonPolygonStyle()
            polygonStyle?.fillColor = Utils.hex2ARgb(170, Constants.heatMapColor[colorIndex] ?: error(""))
            polygonStyle?.strokeWidth = 0f
            it.polygonStyle = polygonStyle
            val pointStyle = GeoJsonPointStyle()
            pointStyle.isDraggable = true
            it.pointStyle = pointStyle
        }

我想用颜色显示所有多边形。

Here is the result I want to show

android polygon geojson
1个回答
0
投票

尝试一下

heatMapLayer = new GeoJsonLayer(googleMap, new JSONObject(airMapGeoJsonLayer.geoJson));
  GeoJsonPolygonStyle style = heatMapLayer.getDefaultPolygonStyle();
  style.setStrokeColor(airMapGeoJsonLayer.strokeColor);
  style.setStrokeWidth(airMapGeoJsonLayer.strokeWidth);
  style.setFillColor(airMapGeoJsonLayer.fillColor);
  heatMapLayer .addLayerToMap();
© www.soinside.com 2019 - 2024. All rights reserved.