这是它的样子:
我的代码:
我真的不明白标记器是如何同时渲染和不渲染的,这毫无意义。
显然,我正在尝试呈现某些图像,但我不知道是哪个导致了它不被呈现。
代码基本上来自示例代码:https://leafletjs.com/examples/quick-start/。这就是我感到困惑的原因。
我已经在index.html中包含了样式和脚本标记。
Map.js
//the next 3 lines changes nothing kept it in bc I found this online as a potential solution
//and didn't want to get this suggested
import L from 'leaflet';
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.imagePath = "/";
function Map() {
let position = [x, y];
return (
<div>
<div id="mapid">
<MapContainer className="leaflet" center={position} zoom={13} scrollWheelZoom={true}>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker position={position}>
<Popup>
A pretty CSS3 popup. <br /> Easily customizable.
</Popup>
</Marker>
</MapContainer>
</div>
</div>
);
};
index.css
.leaflet {
height: 500px;
width: 100%;
}
#mapid {
height: 500px;
margin-top: 50px;
margin-bottom: 150px;
}
img.leaflet-marker-icon {
background-image:
url('<url>');
}
我真的不明白标记器是如何同时渲染和不渲染的,这毫无意义。
显然,我正在尝试呈现某些图像,但我不知道是哪个导致了它不被呈现。
代码基本上来自示例代码:https://leafletjs.com/examples/quick-start/。这就是我感到困惑的原因。
我已经在index.html中包含了样式和脚本标记。