I am using react-google-charts library for my personal project and found there is a way to display markers on the map.
<Chart
width={"200%"}
height={"100%"}
chartType="GeoChart"
data={geoData}
rootProps={{ "data-testid": "1" }}
mapsApiKey="***My Key***"
options={{
displayMode: "markers",
sizeAxis: { maxSize: 10, minSize: 10 },
markerOpacity: 0.9,
backgroundColor: "none",
colors: ["#FFA4A5", "#34D399"],
legend: "none",
datalessRegionColor: "#343434",
}}
/>
But the default marker is circle, and then I am gonna change it to my favorite icon.
In a word, I want to customize the marker with my favorite one.
Is there any way to change/customize the markers in using react-google-charts?
I checked the options for geoChart APIs, but it seems there are not such relevant options.
2
Answers
Unfortunately GeoChart does not have marker customization support.
You can however use the google-maps package for this:
In your code:
Replace YOUR_API_KEY, with your API key.
Don’t forget to render your map in your application:
The google-maps-react library itself does not provide direct support for coloring countries or areas on the map. However, you can achieve this effect by utilizing the Google Maps JavaScript API directly.
To color countries or areas on the map, you can use the Data Layer of the Google Maps JavaScript API. Here’s an example of how you can modify your code to achieve this:
Can you try to add the custom CSS using
before
selector?