rungwiroon/BlazorGoogleMaps

Add support For Multiple colors for different features

skudale24 opened this issue · 3 comments

It would be nice to have support for features in different colors as seen in the Google maps API here:
https://developers.google.com/maps/documentation/javascript/examples/boundaries-choropleth#maps_boundaries_choropleth-typescript

The overridestyle method should be able to achieve that I believe:


var jsonData = "{ \"type\": \"FeatureCollection\"," +
                       "  \"features\": [" +
                       "{ \"type\": \"Feature\"," +
                       " \"id\": 2," +
                       " \"properties\": { \"stroke\": \"#555555\", \"stroke-width\": 2, \"stroke-opacity\": 1 }, " +
                       " \"geometry\": {\"type\": \"LineString\",  \"coordinates\": [ [ 151.219, -33.888], [151.23, -33.869]]}}]}";

        await _map1.InteropObject.Data.AddGeoJson(jsonData);
        var feature = await _map1.InteropObject.Data.GetFeatureById(1);
        await _map1.InteropObject.Data.OverrideStyle(feature, new StyleOptions { StrokeColor = "green", StrokeWeight = 2 });

Will take a look at weekend.
Summer is over so maybe will have more time :).

I changed that AddGeoJson to return features with their guid id. Not you could do request feature.GetId() to return real undeling id.
Also added method to ovveride style, but not sure why it is not working. No error is returned. I will try investigate next time.

612359b#diff-79f1ab0b4c96e080517bf21bd3b2fbfdc041a9fa93848307a388912ef40485b9R603

https://www.nuget.org/packages/BlazorGoogleMaps/3.1.4
Let me know if it works as expected