简体   繁体   中英

How to change marker label color of react-google-maps

I am using @react-google-maps/api library. I've integrated google map but I am facing marker label color, I tried very hard but didn't find any solution. Could someone please help me with how to resolve this issue.

import {
  Marker,
} from "@react-google-maps/api";

{markers.map(({ id, name, position }) => (
        <Marker
          key={id}
          position={position}
          onClick={() => handleActiveMarker(id)}
          label={`${id}`}
        >
          {activeMarker === id ? (
            <InfoWindow onCloseClick={() => setActiveMarker(null)}>
              <div>{name}</div>
            </InfoWindow>
          ) : null}
        </Marker>
      ))}

Try this piece of code:

label={{text:`${id}`,color:'#fff'}}

Add this label attribute in Marker tag

Try this: label: {text: `${id}`, color: "blue"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM