Created
March 5, 2013 23:00
-
-
Save justinlewis/5095156 to your computer and use it in GitHub Desktop.
Add a simple WFS layers to an OpenLayers map from a Geoserver WFS service. Standard approach to getting around the browsers same origin policy with JavaScript.
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
var tipProjects = new OpenLayers.Layer.Vector("TIP Projects 2012 - 2017", { | |
strategies: [new OpenLayers.Strategy.BBOX()], | |
protocol: new OpenLayers.Protocol.Script({ | |
url: "http://gis.drcog.org/geoserver/wfs", | |
callbackKey: "format_options", | |
callbackPrefix: "callback:", | |
params: { | |
service: "WFS", | |
version: "1.1.0", | |
srsName: "EPSG:4326", | |
request: "GetFeature", | |
typeName: "DRCOGPUB:tip_project_points_2012_2017", | |
outputFormat: "json" | |
}, | |
filterToParams: function(filter, params) { | |
if (filter.type === OpenLayers.Filter.Spatial.BBOX) { | |
params.bbox = filter.value.toArray(); | |
if (filter.projection) { | |
params.bbox.push(filter.projection.getCode()); | |
} | |
} | |
return params; | |
} | |
}) | |
}) | |
map.addLayer(tipProjects); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment