I 've put together a very simple React / Leaflet demo but the marker icon is not showing at all. Full running code is here.
Here's what I have in my componentDidMount
method:
componentDidMount() {
this.map = L.map("map-id", {
center: [37.98, 23.72],
zoom: 12,
zoomControl: true
});
const mapboxAccessToken =
"pk.eyJ1IjoibXBlcmRpa2VhcyIsImEiOiJjazZpMjZjMW4wOXJzM2ttc2hrcTJrNG9nIn0.naHhlYnc4czWUjX0-icY7Q";
L.tileLayer(
"https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}",
{
attribution:
'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 25,
id: "mapbox/streets-v11",
accessToken: mapboxAccessToken
}
).addTo(this.map);
L.marker([37.98, 23.72])
.addTo(this.map)
.bindPopup("a marker")
.openPopup();
}
Basically, the popup is visible, but not the marker icon itself. I.e., here's what I see:
<img src='data:image/png;base64, ... GgIwYdwAAAAASUVORK5CYII=")marker-icon.png'
. Removing the suffix")marker-icon.png
in the browser debugger makes the icon appear, but I don't know where it's coming from. In addition there is an empty square around the icon, which probably represents the missing drop shadow.