Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT A.geom, B.%attr% AS descriptor FROM northern_ireland.osni_ward93 AS A, northern_ireland.%t% AS B WHERE LOWER(A.name) = LOWER(B.ward)
- choro_layer = new OpenLayers.Layer.Vector("Colored Map", {
- strategies: [new OpenLayers.Strategy.BBOX()],
- styleMap: choroplethStyles,
- isBaseLayer:false,
- projection: new OpenLayers.Projection("EPSG:4326"),
- protocol: new OpenLayers.Protocol.WFS({
- version: "1.1.0",
- url: "http://localhost:8080/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeNames=cite:view_ni&propertyName=descriptor&viewparams=attr:" + attribute + ";t:" + table,
- viewparams: "attr:" + attribute + ";t:" + table,
- featurePrefix: "cite",
- featureType: "view_ni",
- featureNS: "http://www.opengeospatial.net/cite",
- outputFormat: "application/json",
- readFormat: new OpenLayers.Format.GeoJSON(),
- geometryName: "geom"
- })
- });
- var hoverControl = new OpenLayers.Control.SelectFeature(
- choro_layer, {
- hover: true,
- onBeforeSelect: function(feature) {
- // add code to create tooltip/popup
- popup = new OpenLayers.Popup.Anchored(
- "",
- feature.geometry.getBounds().getCenterLonLat(),
- new OpenLayers.Size(100,50),
- "<div><b>Descriptor value</b>: "+feature.attributes.descriptor+"</div>",
- null,
- true,
- null);
- feature.popup = popup;
- map.addPopup(popup);
- // return false to disable selection and redraw
- // or return true for default behaviour
- return true;
- },
- onUnselect: function(feature) {
- // remove tooltip
- map.removePopup(feature.popup);
- feature.popup.destroy();
- feature.popup=null;
- }
- });
- map.addControl(hoverControl);
- hoverControl.activate();
- map.addLayer(choro_layer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement