Getting WFS data from Geoserver into leaflet

المشرف العام

Administrator
طاقم الإدارة
I'm trying to use a ajax call to load WFS data from geoserver into a GeoJson layer in leaflet.

When I do the following message in the console:

XMLHttpRequest cannot load http://localhost:8080/geoserver/cit...rmat=json&format_options=callback:loadGeoJson. Origin http://localhost is not allowed by Access-Control-Allow-Origin. I know that if you are trying to load wfs into OpenLayers you need a proxy.cgi as per this thread: XMLHttpRequest cannot load http://localhost: /geoserver/wfs. Origin http://localhost is not allowed by Access-Control-Allow-Origin

That script seems to relate only to OpenLayers. My question is can I use this for leaflet and if not how to I get the wfs data? There must be a way round this problem but I can't see anything in the main documentation and I've searched almost exhausted my searching elsewhere.

I have added my script for the leaflet page...

var map = L.map('map').setView([50.370, -4.14], 14);var basemap = L.tileLayer('http://{s}.tile.cloudmade.com/a8ed148d84c2438ba62c2742cac051ae/33356/256/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery

أكثر...
 
أعلى