marker Icon not showing
Map is loading corrrectly but marker icon is not showing
<Map center={position} zoom={this.state.zoom}>
<TileLayer
url={url}
attribution="&copy <a href="http://www.mapmyindia.com/about/privacy-policy">MapMyIndia</a> contributors"
/>
<Marker position={position}>
<Popup>A pretty CSS3 popup.<br />Easily customizable.</Popup>
</Marker>
</Map>
Error:
Failed to load resource: net::ERR_INVALID_URL
Same here P.S. https://github.com/PaulLeCam/react-leaflet/issues/453 here's what solved my problem
@phdog i found the solution use custom marker. this resolve your issue.
This custom marker resolved problem for me (have to give right path for marker image): https://stackoverflow.com/questions/47723812/custom-marker-icon-with-react-leaflet
I found this solution in another page:
`import React, { Component } from 'react'; import L from 'leaflet'; import { Map, TileLayer, Marker, Popup } from 'react-leaflet' import 'leaflet/dist/leaflet.css'; import './style.css';
import icon from 'leaflet/dist/images/marker-icon.png'; import iconShadow from 'leaflet/dist/images/marker-shadow.png';
let DefaultIcon = L.icon({ iconUrl: icon, shadowUrl: iconShadow });
L.Marker.prototype.options.icon = DefaultIcon;`
this work for react-leaflet
I had a similar problem when using leaflet on a react project but the following steps worked for me:
Step 1: I removed the import "leaflet/dist/leaflet.css" line of code from my index.js document. Step 2: I copied and pasted the link below to the CSS file for leaflet from leafletjs.com and pasted it in the header section of my index.html document.
Leafletjs CSS link: ( )