-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react leaflet cluster #4863
Comments
Hi @LeilaEb, I had the same problem, I found about a package called folium which basically ports everything from leafletjs. Here is a sample code that I used for clusters.
|
fix problem.
above steps fix my problem . |
is this still happening in latest release? we did upgrade to react 19 in that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,
have error: 0 , react__WEBPACK_IMPORTED_MODULE_0__.use) is not a function
when use MarkerClusterGroup get above error .
react-leaflt v 4.2.1
leaflet v 1.9.4
react-leaflet-cluster v 2.1.0
react v 18
`export default function LocationContainer(props) {
const [t] = useTranslation();
const [locations, setLocations] = useState([]);
const [recId, setRecId] = useState();
const [recData, setRecData] = useState();
const responseRecord = useGetIORecordById(recId);
const locationIcon = L.icon({
iconUrl: location,
iconRetinaUrl: location,
iconSize: [20, 20],
});
useEffect(() => {
if (responseRecord) {
setRecData(responseRecord);
}
}, [responseRecord]);
useEffect(() => {
if (props.locations) setLocations(props.locations);
else setLocations([]);
}, [props.locations]);
const createClusterCustomIcon = function (cluster) {
return new divIcon({
html:
<span class="cluster-icon">${cluster.getChildCount()}</span>
,className: "custom-marker-cluster",
iconSize: point(33, 33, true),
});
};
return (
<div
style={{
padding: "5px",
margin: "5px",
}}
>
<MapContainer
scrollWheelZoom={true}
bounds={props.markers}
style={{
height: "400px",
width: "100%",
position: "inherit",
margin: "0 auto",
zIndex: 1,
}}
dragging={true}
placeholder
>
{locations !== undefined &&
locations !== null &&
locations?.length > 0 &&
locations.map((item, index) => (
<>
<Marker
key={index}
position={[Number(item?.Latitude), Number(item?.Longitude)]}
icon={locationIcon}
eventHandlers={{
click: (e) => {
setRecId(item.Id);
},
}}
>
<div style={{ with: 500 }}>
</>
))}
{/* /}
{/ /}
{/ */}
);
}`
The text was updated successfully, but these errors were encountered: