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
[email protected]
clevelandmetroparks.com





-----Original Message-----
From: Olle Markljung [mailto:[email protected]] 
Sent: Tuesday, November 29, 2011 5:20 PM
To: [email protected]; [email protected]
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 [[email protected]]
Skickat: den 29 november 2011 19:10
Till: [email protected]
Ä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:[email protected]]Stephen Mather
Geographic Information Systems (GIS) Manager
(216) 635-3243
[email protected]<mailto:[email protected]>
clevelandmetroparks.com<http://www.clemetparks.com/>








------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to