Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. 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)
  2.  
  3. choro_layer = new OpenLayers.Layer.Vector("Colored Map", {
  4. strategies: [new OpenLayers.Strategy.BBOX()],
  5. styleMap: choroplethStyles,
  6. isBaseLayer:false,
  7. projection: new OpenLayers.Projection("EPSG:4326"),
  8. protocol: new OpenLayers.Protocol.WFS({
  9. version: "1.1.0",
  10. 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,
  11. viewparams: "attr:" + attribute + ";t:" + table,
  12. featurePrefix: "cite",
  13. featureType: "view_ni",
  14. featureNS: "http://www.opengeospatial.net/cite",
  15. outputFormat: "application/json",
  16. readFormat: new OpenLayers.Format.GeoJSON(),
  17. geometryName: "geom"
  18. })
  19. });
  20.  
  21. var hoverControl = new OpenLayers.Control.SelectFeature(
  22. choro_layer, {
  23. hover: true,
  24. onBeforeSelect: function(feature) {
  25. // add code to create tooltip/popup
  26. popup = new OpenLayers.Popup.Anchored(
  27. "",
  28. feature.geometry.getBounds().getCenterLonLat(),
  29. new OpenLayers.Size(100,50),
  30. "<div><b>Descriptor value</b>: "+feature.attributes.descriptor+"</div>",
  31. null,
  32. true,
  33. null);
  34. feature.popup = popup;
  35. map.addPopup(popup);
  36. // return false to disable selection and redraw
  37. // or return true for default behaviour
  38. return true;
  39. },
  40. onUnselect: function(feature) {
  41. // remove tooltip
  42. map.removePopup(feature.popup);
  43. feature.popup.destroy();
  44. feature.popup=null;
  45. }
  46. });
  47. map.addControl(hoverControl);
  48. hoverControl.activate();
  49. map.addLayer(choro_layer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement