I am using React with leaflet but I do not know how to change the marker's color from blue to red. I looked at the documentation but I didn't find anything on this.
Here is my code :
import React from 'react';
import { render } from 'react-dom';
import Map from './Map';
class App extends React.Component {
state = { markerPosition: { lat: 49.8419, lng: 24.0315 } };
moveMarker = () => {
const { lat, lng } = this.state.markerPosition;
this.setState({
markerPosition: {
lat: lat + 0.0001,
lng: lng + 0.0001,
}
});
};
render() {
const { markerPosition } = this.state;
return (
<div>
<Map markerPosition={markerPosition} />
<div>Current markerPosition: lat: {markerPosition.lat}, lng: {markerPosition.lng}</div>
<button
onClick={this.moveMarker}
>
Move marker
</button>
</div>
);
}
}
render(<App />, document.getElementById('root'));
https://codesandbox.io/s/m4k3x1ynl8
Do you know how can I do this?
Thank you very much!
dist/images/marker-icon.png
, see thisMap
component in the linked sandbox.