0

I use React-Leaflet and want to show only country one country .

I got geoJSON of country and gave style to it but other countries keep showing.

How may I hide or delete other countries ?

function style(feature) {
return {
  fillColor: "grey",
  weight: 2,
  opacity: 1,
  color: "black", //Outline color
  fillOpacity: 1
}; }

//

<MapContainer
          center={position}
          style={{ height: 650 }}
          zoom={window.innerWidth <= 720 ? 5 : 6}
          doubleClickZoom={false}
          dragging={window.innerWidth <= 720 ? true : false}
          tap={false}
          scrollWheelZoom={false}
          zoomControl={false}
        >

          <TileLayer
            attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
          />
                <GeoJSON  data={geo} style={style} />
3
  • 1
    you can filter your geo data before giving as prop. I assume "geo" data is a featureCollection so you can filter its features by property name, id or something similar. Commented Apr 8, 2022 at 13:10
  • I want to show only one country the rest of all shouldn't be display . How may I do ? (Tr haritasını geoJSON olarak aldım fakat sadece onu render etmek kalan yerlerin olmamasını istiyorum. )
    – Fatih Can
    Commented Apr 8, 2022 at 14:11
  • Did you get the solution? If yes then please share
    – Rana Faraz
    Commented Aug 9, 2022 at 14:57

0

Browse other questions tagged or ask your own question.