erdigokce / turkey-map-react

An out-of-the-box city map of Turkey for React JS applications.
https://www.npmjs.com/package/turkey-map-react
MIT License
73 stars 8 forks source link

Changing city color #1

Closed YBerkay closed 3 years ago

YBerkay commented 4 years ago

Hello Erdi,

How can I change city color by plateNumber. I don't want to change color of the all cities.

erdigokce commented 4 years ago

Hello Erdi,

How can I change city color by plateNumber. I don't want to change color of the all cities.

Hello,

Maybe City Component Wrapping feature works for you. You can wrap a div and style it based on city data.

Please see more on readme : https://github.com/erdigokce/turkey-map-react#city-component-wrapping

ErtugrulBEKTIK commented 1 year ago

Hi,

I can achieve that by using cityWrapper and customStyle props together. Here is an example:

cityWrapper={(cityComponent, cityData) => (
    <g fill={cityData.plateNumber % 2 == 0 ? 'red' : 'blue'}>
        {cityComponent}
    </g>
)}
customStyle={{
    idleColor: 'inherit',
    hoverColor: 'purple',
}}