From: Stephen V. M. <sv...@cl...> - 2011-11-30 16:54:56
|
Ah, it was the JSONP portion I was struggling with. I was reading the original dialog (from 1.6 or something) about script wrappers, and I think the flag changed. Thanks Olle, Steve Stephen Mather Geographic Information Systems (GIS) Manager (216) 635-3243 sv...@cl... clevelandmetroparks.com -----Original Message----- From: Olle Markljung [mailto:oll...@as...] Sent: Tuesday, November 29, 2011 5:20 PM To: sv...@cl...; geo...@li... Subject: SV: [Geoserver-users] Leaflet and GeoServer Hello Steve, I hadn't..but I got so qurious that I did :) GeoServer sends back valid GeoJSON by specifying outputFormat=json in the query. It can also repond with JSONP by adding i.e. format_options=callback:loadGeoJson. I added this to the geojson sample provided by leaflet just under var geojson = new L.GeoJSON();. function loadGeoJson(data) { geojson.addGeoJSON(data); } var geoJsonUrl = "http://localhost:8080/geoserver/ows?service=WFS&version=1.1.0&request=GetFe ature&typeName=sf:bugsites&srsName=EPSG:4326&outputFormat=json&format_option s=callback:loadGeoJson"; $.ajax({ url: geoJsonUrl, dataType: 'jsonp' }); I also referenced jQuery to help me with the call and made the map start at new L.LatLng(44.384907731239096, -103.86762869467091) To sum up..it just worked :) ________________________________________ Från: Stephen V. Mather [sv...@cl...] Skickat: den 29 november 2011 19:10 Till: geo...@li... Ämne: [Geoserver-users] Leaflet and GeoServer Hi All, Has anyone played with leaflet+geoserver? Any tips/tricks to getting GeoJSON back in a form that leaflet likes, or do I need to use custom JS to modify the input. Thanks, Steve [cid:image001.png@01CCADED.B6347F90]Stephen Mather Geographic Information Systems (GIS) Manager (216) 635-3243 sv...@cl...<mailto:sv...@cl...> clevelandmetroparks.com<http://www.clemetparks.com/> |