Reactでleaflet①
/sample-app/src/components/Map0.js
import React, { useEffect } from "react";
import L from "leaflet";
import "leaflet/dist/leaflet.css";
import icon from "leaflet/dist/images/marker-icon.png";
import shadow from "leaflet/dist/images/marker-shadow.png";
L.Marker.prototype.options.icon = L.icon({
iconUrl: icon,
shadowUrl: shadow,
});
const Map0 = () => {
useEffect(() => {
// https://leafletjs.com/
var map = L.map("map").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();
}, []);
return <div id="map" style={{ height: "100vh" }}></div>;
};
export default Map0;
Author And Source
この問題について(Reactでleaflet①), 我々は、より多くの情報をここで見つけました https://qiita.com/yono2844/items/41f474ac26c339dbcade著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .