When using react-leaflet with create-react-app, for Marker it shows <img src=[object Module]> in console after changing the default icon as given in here - https://github.com/PaulLeCam/react-leaflet/issues/453#issuecomment-541142178 . Hence I am unable to view the marker Icon on Map.

delete L.Icon.Default.prototype._getIconUrl;
    iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
    iconUrl: require('leaflet/dist/images/marker-icon.png'),
    shadowUrl: require('leaflet/dist/images/marker-shadow.png')
return (
        <Marker position={location}> </Marker>
  • Since this is as workaround for a bug in react-leaflet, GIS SE site is not the right place to resolve the problem. – TomazicM Apr 20 at 15:57
  • @TomazicM Can you please explain in detail what you mean by "workaround" exactly? It would be of great help. Thanks. – VertikaJain Apr 20 at 18:00
  • According to the provided link in your question all those code snippets are workarounds for problem in react-leaflet when using create-react-app webpack config. Let me cite from the page: "When it will work "out of the box"? Strange prop deleteing and monkey patching of "mergeOptions' - smells bad ((" – TomazicM Apr 20 at 19:23
  • I got your point @TomazicM . Thanks :) – VertikaJain Apr 21 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.