Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Feature Selection
- select = new OpenLayers.Layer.Vector("Selection", {
- styleMap: new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
- });
- map.addLayers([select]);
- selectControl = new OpenLayers.Control.GetFeature({
- protocol: OpenLayers.Protocol.WFS.fromWMSLayer(PointsLayer),
- box: true,
- hover: false,
- multipleKey: "shiftKey",
- toggleKey: "ctrlKey"
- });
- selectControl.events.register("featureselected", this, function (e) {
- // How do I popup a window with feature info, is it here??
- select.addFeatures([e.feature]);
- });
- selectControl.events.register("featureunselected", this, function (e) {
- select.removeFeatures([e.feature]);
- });
- map.addControl(selectControl);
- selectControl.activate();
- // Register click event to get features
- map.events.register('click', map, function (e) {
- var url = baseLayer.getFullRequestString({
- REQUEST: "GetFeatureInfo",
- EXCEPTIONS: "application/vnd.ogc.se_xml",
- BBOX: map.getExtent().toBBOX(),
- X: e.xy.x,
- Y: e.xy.y,
- INFO_FORMAT: 'text/html',
- LAYERS: map.layers[0].params.LAYERS + "," +
- map.layers[1].params.LAYERS,
- QUERY_LAYERS: map.layers[0].params.LAYERS + "," +
- map.layers[1].params.LAYERS,
- WIDTH: map.size.w,
- HEIGHT: map.size.h
- });
- function handler(request) {
- answer = request.responseText.length;
- if (answer <= 1)
- {
- var strTemp = "<HTML><BODY>ERROR RETRIEVING FEATURE</BODY></HTML>";
- open_new_window(strTemp);
- }
- else
- {
- //open_new_window(url);
- open_new_window(request.responseText);
- }
- }
- var request = OpenLayers.Request.GET({
- url: url,
- callback: handler
- });
- });
- function open_new_window(windowText)
- {
- new_window = open("", "Feature Window", "width=300,height=170,left=10,top=10");
- // open new document
- new_window.document.open();
- // Text of the new document
- new_window.document.write(windowText);
- // close the document
- new_window.document.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement