Skip to content

Commit 084dc74

Browse files
committed
Fix Leaflet marker icon paths to resolve issues caused by bundler. Updated icon options to ensure proper rendering of default markers.
1 parent c72fcc8 commit 084dc74

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/index.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,22 @@ import {
2323
} from "./services/User/User";
2424
import "./theme.scss";
2525
import "./styles/index.css";
26+
import L from "leaflet";
2627
import "leaflet/dist/leaflet.css";
2728
import "mapillary-js/dist/mapillary.css";
2829
import "leaflet.markercluster/dist/MarkerCluster.css";
2930
import "leaflet.markercluster/dist/MarkerCluster.Default.css";
31+
import markerIcon2x from "leaflet/dist/images/marker-icon-2x.png";
32+
import markerIcon from "leaflet/dist/images/marker-icon.png";
33+
import markerShadow from "leaflet/dist/images/marker-shadow.png";
34+
35+
// Fix Leaflet default marker icon paths broken by bundler
36+
delete L.Icon.Default.prototype._getIconUrl;
37+
L.Icon.Default.mergeOptions({
38+
iconRetinaUrl: markerIcon2x,
39+
iconUrl: markerIcon,
40+
shadowUrl: markerShadow,
41+
});
3042

3143
// Setup Apollo graphql client
3244
const graphqlClient = new ApolloClient({

0 commit comments

Comments
 (0)