diff --git a/config/code_samples/vector_leaflet.txt b/config/code_samples/vector_leaflet.txt index 7d9f0f48..86af25f5 100644 --- a/config/code_samples/vector_leaflet.txt +++ b/config/code_samples/vector_leaflet.txt @@ -17,7 +17,7 @@ maxZoom: 19, }).addTo(map) var geojsonLayer = new L.GeoJSON.AJAX("<>?service=WFS&" + - "version=1.1.0&request=GetFeature&typename=<>" + + "version=1.1.0&request=GetFeature&typename=<>&" + "outputFormat=application/json&srsname=EPSG:4326", { onEachFeature: function (feature, layer) { var popupContent = ''; diff --git a/config/code_samples/vector_python.txt b/config/code_samples/vector_python.txt index fc863edb..88fde678 100644 --- a/config/code_samples/vector_python.txt +++ b/config/code_samples/vector_python.txt @@ -2,6 +2,10 @@ # Before running this code, install or check for these libraries # !pip install geopandas folium +import requests +import geopandas as gpd +import folium + # Accept user input for the GeoServer URL and the typeName of the layer geoserver_url = "<>?" type_name = "<>" @@ -18,6 +22,9 @@ params = { # Send a GET request to the GeoServer WFS service response = requests.get(geoserver_url, params=params) +# Load the features from the WFS service into a GeoDataFrame +gdf = gpd.read_file(response.text) + # Get the bounds of the GeoDataFrame bounds = gdf.total_bounds @@ -27,10 +34,6 @@ center = [(bounds[1] + bounds[3]) / 2, (bounds[0] + bounds[2]) / 2] # Create the map m = folium.Map(location=center, zoom_start=2) -# Load the features from the WFS service into a GeoDataFrame -gdf = gpd.read_file(response.text) - - # Add the GeoDataFrame to the map as a GeoJson layer folium.GeoJson(gdf).add_to(m)