1 when adding marker using leaflet in webpack, use the default marker to report an error
the default marker name will be added to the transcoded base64 icon
related configurations in webpack.config.js
resolve: {
alias: {
"@":path.resolve(__dirname, "./src"),
leaflet_css: __dirname + "/node_modules/leaflet/dist/leaflet.css",
leaflet_marker: __dirname + "/node_modules/leaflet/dist/images/marker-icon.png",
leaflet_marker_2x: __dirname + "/node_modules/leaflet/dist/images/marker-icon-2x.png",
leaflet_marker_shadow: __dirname + "/node_modules/leaflet/dist/images/marker-shadow.png",
}
},
Code
import "leaflet_css";
import L from "leaflet";
(function(){
var map = L.map("map-osm-leaflet").setView([51.505, -0.09], 13);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: " <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors"
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup("A pretty CSS3 popup.<br> Easily customizable.")
.openPopup();
})();