JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.75k stars 426 forks source link

Data-driven style #3239

Open ericwallen opened 1 year ago

ericwallen commented 1 year ago

Hello, I am trying to use data-driven styling. Tried implementing it like this:

    const onLoad = useCallback(function callback(map) {

        const bounds = new window.google.maps.LatLngBounds(center)
        map.fitBounds(bounds);

        let layer = map.getFeatureLayer(window.google.maps.FeatureType.COUNTRY)
        layer.style = {
            'strokeColor': 'blue',
            'strokeWeight' : 1
        }

        setMap(map)
    }, [])

Does anyone know how to implement this correctly? I am kinda scratching my head right now. Tried using the information from this video https://www.youtube.com/watch?v=tAR63GBwk90 but not getting anywhere with it.

Any help would be much appreciated. Thanks!

subu873 commented 1 year ago

I implemented Data driven using @ubilabs/google-maps-react-hooks this library