Comments (3)
this is just a small app for test assignment at my college, I know forking a repository is a bit complicated, so here's a demo video
ini.mp4
from react-leaflet.
Update
I decided to put code snippet instead here
Here's my GIS component
import { useGis } from '@/hooks/use-gis'
import { GisAreaItem } from './gis-area-item'
import type { LatLngExpression } from 'leaflet'
import { Loader2Icon } from 'lucide-react'
import { MapContainer, TileLayer } from 'react-leaflet'
export function Gis() {
const query = useGis()
const centerMap = [-6.118547, 106.153355] as LatLngExpression
if (query.status === 'pending') {
return (
<div className='py-4'>
<div className='flex flex-col items-center justify-center gap-2 w-full h-96 md:h-[30rem] aspect-square md:aspect-video rounded-md overflow-hidden bg-gray-100'>
<Loader2Icon size='4rem' className='animate-spin' />
<p className='text-sm'>Memuat Data</p>
</div>
</div>
)
}
if (query.status === 'error') {
return <p className='text-center py-4'>Terjadi error ketika memuat data</p>
}
return (
<section className='py-4'>
<div className='rounded-md overflow-hidden'>
<MapContainer
zoom={13}
center={centerMap}
scrollWheelZoom={false}
className='w-full h-96 md:h-[30rem] '
>
<TileLayer
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
/>
{query.data.map((item, i) => (
<GisAreaItem {...item} key={item.location + i} />
))}
</MapContainer>
</div>
</section>
)
}
And here's my vector layer component
import { useGisDialog } from '@/hooks/use-gis-dialog'
import { TCoordinateItem } from '@/~types'
import type { LatLngExpression } from 'leaflet'
import { CircleMarker } from 'react-leaflet'
function getColor(level: TCoordinateItem['level']) {
switch (level) {
case 'high':
return 'red'
case 'medium':
return 'orange'
default:
return 'yellow'
}
}
export function GisAreaItem(props: TCoordinateItem) {
const openGis = useGisDialog((store) => store.openDialog)
const color = getColor(props.level)
function onClickLayer() {
openGis(props)
}
return (
<CircleMarker
eventHandlers={{
click: onClickLayer,
}}
center={props.coordinates as LatLngExpression}
pathOptions={{ color }}
radius={props.radius}
/>
)
}
from react-leaflet.
I am so embarrassed right now, I'll close this issue
In case anyone do this in the future
Solution:
- Check the documentation site again
- Make sure to use
<Circle />
and not<CircleMarker />
Have a great day everyone
from react-leaflet.
Related Issues (20)
- [Question] React-leaflet does not let react-modal close on first click HOT 2
- Image shrinking when using ImageOverlay
- Marker with invalid lat, long values are shown in Antartica
- Map are don't have HoangSa and TruongSa islands belong to VIetNam by defaults
- Map rendered with missing parts HOT 8
- ESM packages (@react-leaflet/core) need to be imported.
- Iām interested in enhancing the documentation.
- BUG: Control Component event handling HOT 2
- How to add an additional layer?
- MapContainer whenReady doesn't receive target parameter from Leaflet HOT 1
- Problem with rendering OS Maps Leisure Layers HOT 1
- [Turbopack] Parsing css source code failed HOT 5
- Help please
- error rendering <Marker> component in react
- Is everything okay with Nextjs v14.1.0 + React v18? Maps doesn't render HOT 4
- Get Distance Function? HOT 2
- How to hide the API Key in the TileLayer?
- Marker is missing data type in typescript definition
- Is there a way to calculate a circle with a 150-meter radius around the marker? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-leaflet.