我已经导入了 Leaflet 模块以及一些删除图标的代码。
import L from "leaflet";
import { Map, TileLayer, Marker, Popup } from "react-leaflet";
import "leaflet/dist/leaflet.css";
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.mergeOptions({
iconRetinaUrl: require("./images/marker-icon-2x.png"),
iconUrl: require("./images/marker-icon.png"),
shadowUrl: require("./images/marker-shadow.png"),
});
标记图标位于我的图像文件夹中。我也试过直接要求:
L.Icon.Default.mergeOptions({
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"),
});
但我仍然得到一个坏掉的标记。