Last active
November 1, 2019 12:05
-
-
Save iamtekson/f8be2d75e308081aef86ca151a347d5b to your computer and use it in GitHub Desktop.
This is the ajax-request of wfs layer in leaflet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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