From ea346a785dc1b3f7c156f6fc33da634e1f1a627b Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Tue, 12 Aug 2014 21:56:44 +0200 Subject: Adding jquery, flot and openlayers to be included with the GEM. --- misc/openlayers/examples/sld.js | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 misc/openlayers/examples/sld.js (limited to 'misc/openlayers/examples/sld.js') diff --git a/misc/openlayers/examples/sld.js b/misc/openlayers/examples/sld.js new file mode 100644 index 0000000..888a9c6 --- /dev/null +++ b/misc/openlayers/examples/sld.js @@ -0,0 +1,102 @@ +var map, sld, waterBodies; +var format = new OpenLayers.Format.SLD(); +function init() { + + map = new OpenLayers.Map('map', {allOverlays: true}); + var layers = createLayers(); + map.addLayers(layers); + + waterBodies = layers[2]; + map.addControl(new OpenLayers.Control.SelectFeature( + waterBodies, {hover: true, autoActivate: true} + )); + map.addControl(new OpenLayers.Control.LayerSwitcher()); + + OpenLayers.Request.GET({ + url: "tasmania/sld-tasmania.xml", + success: complete + }); +} + +// handler for the OpenLayers.Request.GET function in the init method +function complete(req) { + sld = format.read(req.responseXML || req.responseText); + buildStyleChooser(); + setLayerStyles(); + + map.zoomToExtent(new OpenLayers.Bounds(143,-39,150,-45)); +} + +function createLayers() { + // the name of each layer matches a NamedLayer name in the SLD document + var layerData = [{ + name: "Land", + url: "tasmania/TasmaniaStateBoundaries.xml" + }, { + name: "Roads", + url: "tasmania/TasmaniaRoads.xml" + }, { + name: "WaterBodies", + url: "tasmania/TasmaniaWaterBodies.xml" + }, { + name: "Cities", + url: "tasmania/TasmaniaCities.xml" + }]; + + var layers = []; + for (var i=0,ii=layerData.length; i