0

I can use the data in the GeoServer from the JSON file, but I cannot use it directly from the GeoServer. I can get data as WMS I'm using allow CORS as a Chrome extension (no CORS issues either).

import { MapContainer, TileLayer, GeoJSON, Popup, LayersControl, LayerGroup, WMSTileLayer } from 'react-leaflet'
import 'leaflet/dist/leaflet.css'
import React, { useEffect, useState } from 'react'
import axios from 'axios'
import ParselService from '../services/ParselService'
import Data from '../services/data.json'


export default function MapComp() { 
    const [parseller,setParseller]=useState([]);
    useEffect(() =>{
         const baseUrl="http://localhost:8081/geoserver/parseller/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=parseller%3ATUR_ADM0&maxFeatures=50&outputFormat=application%2Fjson"
            axios.get(baseUrl).then(resp =>setParseller(resp.data))
            
    },[]);
    const position = [39,35]
    const onEachParsel = (parsel,layer) => {
       // const parselName=parsel.properties.party;
    //    layer.bindPopup(parselName)
    };
    return (
         <>
         {/* {Array.from(parseller,parsel =>{
            <p>{parsel.features}</p>
         })} */}
        <MapContainer id="map" center={position} zoom={6}>
        <LayersControl position="topright">
        <LayerGroup>
            <TileLayer
                attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
                url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            />
        </LayerGroup>
  
      <LayersControl.Overlay checked name="Evler">
        <LayerGroup>

        </LayerGroup>
      </LayersControl.Overlay>
      <LayersControl.Overlay checked name="Parseller">
        <GeoJSON
            data={parseller.features}
            onEachFeature={onEachParsel}
            />     
      </LayersControl.Overlay>
    </LayersControl>
        </MapContainer>
        </>
    )
}        
        ```
2
  • So what goes wrong? Geojson is a native format for wfs in geoserver
    – Ian Turton
    Aug 28 at 17:11
  • I guess the incoming data stays under the tilelayer because if I comment the tilelayer, the data appears. I used zindex but it didn't work
    – Giray
    Aug 28 at 18:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.