Keith Becker
Keith Becker

Reputation: 19

How to style the React google map marker using the given image file

Now I am using React-google-map component and want to change the marker to my own image. At this moment, I can't change the size of the marker using CSS. I've tried as follows:

var image = {
    url: '../images/icons/yellow.png',
    size: 10
};

return (
    <Marker 
        position={location}
        icon={image}
        onClick={this.handleMarkerClick.bind(this, marker)}
    />
    );

If you know the solution, please kindly let me know.

Thanks for your help in advance.

Upvotes: 1

Views: 6548

Answers (1)

Manan Sheth
Manan Sheth

Reputation: 316

You have to pass a url of the image, like: icon={url}

Example:

return (
    <Marker 
    position={location}
    icon={"http://maps.google.com/mapfiles/ms/icons/blue.png"}
    />
);

For more info: github.com/tomchentw/react-google-maps/issues/486

Upvotes: 3

Related Questions