Skip to content

Instantly share code, notes, and snippets.

@iamtekson
Last active November 1, 2019 12:05
Show Gist options
  • Save iamtekson/f8be2d75e308081aef86ca151a347d5b to your computer and use it in GitHub Desktop.
Save iamtekson/f8be2d75e308081aef86ca151a347d5b to your computer and use it in GitHub Desktop.
This is the ajax-request of wfs layer in leaflet
//Geoserver Web Feature Service
$.ajax('http://localhost:8080/geoserver/wfs',{
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typename: 'workspace:layer_name',
srsname: 'EPSG:4326',
outputFormat: 'text/javascript',
},
dataType: 'jsonp',
jsonpCallback:'callback:handleJson',
jsonp:'format_options'
});
// the ajax callback function
function handleJson(data) {
selectedArea = L.geoJson(data).addTo(map);
map.fitBounds(selectedArea.getBounds());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment