Skip to content

GeoJsonFeature.setPolygonStyle() doesn't redraw polygon if the feature was previously added via GeoJsonLayer.addFeature() #1050

Description

@appach22

Summary

First I add GeoJsonLayer without features to map. Then I continiously add features using GeoJsonLayer.addFeature() and all the features are appearing on the map. Next I try to call GeoJsonFeature.setPolygonStyle() on the added features, but corresponding polygons don't change their appearance.

Expected behavior

Calling GeoJsonFeature.setPolygonStyle() should redraw the feature with the given style.

Observed behavior

The feature's appearance remains the same as before.

Environment details

Library version 2.3.0

Code example

// Add layer with empty features array
val geoJsons = JSONArray()
val geoJson = JSONObject()
geoJson.put("type", "FeatureCollection")
geoJson.put("features", geoJsons)
val layer = GeoJsonLayer(googleMap, geoJson)
val style = layer.defaultPolygonStyle
style.strokeColor = Color.RED
layer.addLayerToMap()

// This will draw the feature with red stroke
layer.addFeature(geoJsonFeature)

// Changing stroke color
val style = geoJsonFeature.polygonStyle
style.strokeColor = Color.BLUE
// This line should affect the polygon appearance but it doesn't
geoJsonFeature.polygonStyle = style

I suppose that the reason is Layer.addFeature() calls improper version of underlyed renderer's addFeature() (Renderer.addFeature() instead of GeoJsonRenderer.addFeature())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p4An issue that should be addressed eventually.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions