我是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
}
我想用颜色显示所有多边形。
尝试一下
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();