"+description+"
"; -} -var _43d=new OpenLayers.Feature(this,_433,data); -var _43e=_43d.createMarker(); -_43e.events.register("click",_43d,this.markerClick); -this.addMarker(_43e); -} -} -} -} -},markerClick:function(evt){ -sameMarkerClicked=(this==this.layer.selectedFeature); -this.layer.selectedFeature=(!sameMarkerClicked)?this:null; -for(var i=0;i'+description+'
'; + } + var feature = new OpenLayers.Feature(this, location, data); + var marker = feature.createMarker(); + marker.events.register('click', feature, this.markerClick); + this.addMarker(marker); + } + } + } + } + }, + + /** + * @param {Event} evt + */ + markerClick: function(evt) { + sameMarkerClicked = (this == this.layer.selectedFeature); + this.layer.selectedFeature = (!sameMarkerClicked) ? this : null; + for(var i=0; i < this.layer.map.popups.length; i++) { + this.layer.map.removePopup(this.layer.map.popups[i]); + } + if (!sameMarkerClicked) { + this.layer.map.addPopup(this.createPopup()); + } + Event.stop(evt); + } +}); + + +// @require: OpenLayers/Layer/Grid.js +/** +* @class +*/ +OpenLayers.Layer.WMS = Class.create(); +OpenLayers.Layer.WMS.prototype = + Object.extend( new OpenLayers.Layer.Grid(), { + + /** @final @type hash */ + DEFAULT_PARAMS: { service: "WMS", + version: "1.1.1", + request: "GetMap", + styles: "", + exceptions: "application/vnd.ogc.se_inimage", + format: "image/jpeg" + }, + + /** + * @constructor + * + * @param {str} name + * @param {str} url + * @param {hash} params + */ + initialize: function(name, url, params) { + OpenLayers.Layer.Grid.prototype.initialize.apply(this, arguments); + OpenLayers.Util.applyDefaults(this.params, this.DEFAULT_PARAMS); + }, + + /** + * @param {String} name + * @param {hash} params + * + * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in + * parameters merged in. + * @type OpenLayers.Layer.WMS + */ + clone: function (name, params) { + var mergedParams = {}; + Object.extend(mergedParams, this.params); + Object.extend(mergedParams, params); + var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams); + obj.setTileSize(this.tileSize); + return obj; + }, + + /** + * addTile creates a tile, initializes it (via 'draw' in this case), and + * adds it to the layer div. + * + * @param {OpenLayers.Bounds} bounds + * + * @returns The added OpenLayers.Tile.Image + * @type OpenLayers.Tile.Image + */ + addTile:function(bounds,position) { + url = this.getFullRequestString( + {bbox:bounds.toBBOX(), + width:this.tileSize.w, + height:this.tileSize.h}); + var tile = new OpenLayers.Tile.Image(this, position, bounds, + url, this.tileSize); + tile.draw(); + this.div.appendChild(tile.img); + return tile; + }, + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Layer.WMS" +}); +// @require: OpenLayers/Layer/Grid.js +// @require: OpenLayers/Layer/Markers.js +/** +* @class +*/ +OpenLayers.Layer.WFS = Class.create(); +OpenLayers.Layer.WFS.prototype = + Object.extend(new OpenLayers.Layer.Grid(), + Object.extend(new OpenLayers.Layer.Markers(), { + + /** @type Object */ + featureClass: null, + + /** @final @type hash */ + DEFAULT_PARAMS: { service: "WFS", + version: "1.0.0", + request: "GetFeature", + typename: "docpoint" + }, + + /** + * @constructor + * + * @param {str} name + * @param {str} url + * @param {hash} params + * @param {Object} featureClass + */ + initialize: function(name, url, params, featureClass) { + this.featureClass = featureClass; + + var newArguments = new Array(); + if (arguments.length > 0) { + newArguments.push(name, url, params); + } + OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments); + + if (arguments.length > 0) { + OpenLayers.Util.applyDefaults(this.params, this.DEFAULT_PARAMS); + } + }, + + /** + * @param {OpenLayers.Bounds} bounds + * @param {Boolean} zoomChanged + */ + moveTo: function(bounds, zoomChanged) { + OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments); + OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments); + }, + + /** + * @param {String} name + * @param {hash} params + * + * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in + * parameters merged in. + * @type OpenLayers.Layer.WMS + */ + clone: function (name, params) { + var mergedParams = {} + Object.extend(mergedParams, this.params); + Object.extend(mergedParams, params); + var obj = new OpenLayers.Layer.WFS(name, this.url, mergedParams); + obj.setTileSize(this.tileSize); + return obj; + }, + + /** + * addTile creates a tile, initializes it (via 'draw' in this case), and + * adds it to the layer div. + * + * @param {OpenLayers.Bounds} bounds + * + * @returns The added OpenLayers.Tile.WFS + * @type OpenLayers.Tile.WFS + */ + addTile:function(bounds, position) { + url = this.getFullRequestString( + { bbox:bounds.toBBOX() }); + var tile = new OpenLayers.Tile.WFS(this, position, bounds, + url, this.tileSize); + tile.draw(); + return tile; + }, + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Layer.WFS" +} +) +); +// @require: OpenLayers/Popup.js + +/** +* @class +*/ +OpenLayers.Popup.Anchored = Class.create(); +OpenLayers.Popup.Anchored.prototype = + Object.extend( new OpenLayers.Popup(), { + + /** "lr", "ll", "tr", "tl" - relative position of the popup. + * @type String */ + relativePosition: null, + + /** Object which must have expose a 'size' (OpenLayers.Size) and + * 'offset' (OpenLayers.Pixel) + * @type Object */ + anchor: null, + + /** + * @constructor + * + * @param {String} id + * @param {OpenLayers.LonLat} lonlat + * @param {OpenLayers.Size} size + * @param {String} contentHTML + * @param {Object} anchor Object which must expose a + * - 'size' (OpenLayers.Size) and + * - 'offset' (OpenLayers.Pixel) + * (this is generally an OpenLayers.Icon) + */ + initialize:function(id, lonlat, size, contentHTML, anchor) { + var newArguments = new Array(id, lonlat, size, contentHTML); + OpenLayers.Popup.prototype.initialize.apply(this, newArguments); + + this.anchor = (anchor != null) ? anchor + : { size: new OpenLayers.Size(0,0), + offset: new OpenLayers.Pixel(0,0)}; + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns Reference to a div that contains the drawn popup + * @type DOMElement + */ + draw: function(px) { + if (px == null) { + if ((this.lonlat != null) && (this.map != null)) { + px = this.map.getLayerPxFromLonLat(this.lonlat); + } + } + + //calculate relative position + this.relativePosition = this.calculateRelativePosition(px); + + return OpenLayers.Popup.prototype.draw.apply(this, arguments); + }, + + /** + * @private + * + * @param {OpenLayers.Pixel} px + * + * @returns The relative position ("br" "tr" "tl "bl") at which the popup + * should be placed + * @type String + */ + calculateRelativePosition:function(px) { + var lonlat = this.map.getLonLatFromLayerPx(px); + + var extent = this.map.getExtent(); + var quadrant = extent.determineQuadrant(lonlat); + + return OpenLayers.Bounds.oppositeQuadrant(quadrant); + }, + + /** + * @param {OpenLayers.Pixel} px + */ + moveTo: function(px) { + + var newPx = this.calculateNewPx(px); + + var newArguments = new Array(newPx); + OpenLayers.Popup.prototype.moveTo.apply(this, newArguments); + }, + + /** + * @param {OpenLayers.Size} size + */ + setSize:function(size) { + OpenLayers.Popup.prototype.setSize.apply(this, arguments); + + if ((this.lonlat) && (this.map)) { + var px = this.map.getLayerPxFromLonLat(this.lonlat); + this.moveTo(px); + } + }, + + /** + * @private + * + * @param {OpenLayers.Pixel} px + * + * @returns The the new px position of the popup on the screen + * relative to the passed-in px + * @type OpenLayers.Pixel + */ + calculateNewPx:function(px) { + var newPx = px.offset(this.anchor.offset); + + var top = (this.relativePosition.charAt(0) == 't'); + newPx.y += (top) ? -this.size.h : this.anchor.size.h; + + var left = (this.relativePosition.charAt(1) == 'l'); + newPx.x += (left) ? -this.size.w : this.anchor.size.w; + + return newPx; + }, + + CLASS_NAME: "OpenLayers.Popup.Anchored" +}); +// @require: OpenLayers/Popup/Anchored.js + +/** +* @class +*/ +OpenLayers.Popup.AnchoredBubble = Class.create(); + +//Border space for the rico corners +OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5; + +OpenLayers.Popup.AnchoredBubble.prototype = + Object.extend( new OpenLayers.Popup.Anchored(), { + + /** @type DOMElement */ + contentDiv:null, + + + /** + * @constructor + * + * @param {String} id + * @param {OpenLayers.LonLat} lonlat + * @param {OpenLayers.Size} size + * @param {String} contentHTML + * @param {Object} anchor Object which must expose a + * - 'size' (OpenLayers.Size) and + * - 'offset' (OpenLayers.Pixel) + * (this is generally an OpenLayers.Icon) + */ + initialize:function(id, lonlat, size, contentHTML, anchor) { + OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns Reference to a div that contains the drawn popup + * @type DOMElement + */ + draw: function(px) { + + OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments); + + // make the content Div + var contentSize = this.size.copyOf(); + contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); + + var id = this.div.id + "-contentDiv"; + this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, + null, "relative", null, + "auto"); + this.div.appendChild(this.contentDiv); + this.setContentHTML(); + + this.setRicoCorners(true); + + //set the popup color and opacity + this.setBackgroundColor(); + this.setOpacity(); + + return this.div; + }, + + /** + * @param {OpenLayers.Size} size + */ + setSize:function(size) { + OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); + + if (this.contentDiv != null) { + + var contentSize = this.size.copyOf(); + contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); + + this.contentDiv.style.height = contentSize.h + "px"; + + //size has changed - must redo corners + this.setRicoCorners(false); + } + }, + + /** + * @param {String} color + */ + setBackgroundColor:function(color) { + if (color != undefined) { + this.backgroundColor = color; + } + + if (this.div != null) { + if (this.contentDiv != null) { + this.div.style.background = "transparent"; + Rico.Corner.changeColor(this.contentDiv, this.backgroundColor); + } + } + }, + + /** + * @param {float} opacity + */ + setOpacity:function(opacity) { + if (opacity != undefined) { + this.opacity = opacity; + } + + if (this.div != null) { + if (this.contentDiv != null) { + Rico.Corner.changeOpacity(this.contentDiv, this.opacity); + } + } + }, + + /** Bubble Popups can not have a border + * + * @param {int} border + */ + setBorder:function(border) { + this.border = 0; + }, + + /** + * @param {String} contentHTML + */ + setContentHTML:function(contentHTML) { + if (contentHTML != null) { + this.contentHTML = contentHTML; + } + + if (this.contentDiv != null) { + this.contentDiv.innerHTML = this.contentHTML; + } + }, + + /** + * @private + * + * @param {Boolean} firstTime Is this the first time the corners are being + * rounded? + * + * update the rico corners according to the popup's + * current relative postion + */ + setRicoCorners:function(firstTime) { + + var corners = this.getCornersToRound(this.relativePosition); + var options = {corners: corners, + color: this.backgroundColor, + bgColor: "transparent", + blend: false}; + + if (firstTime) { + Rico.Corner.round(this.div, options); + } else { + Rico.Corner.reRound(this.contentDiv, options); + //set the popup color and opacity + this.setBackgroundColor(); + this.setOpacity(); + } + }, + + /** + * @private + * + * @returns The proper corners string ("tr tl bl br") for rico + * to round + * @type String + */ + getCornersToRound:function() { + + var corners = ['tl', 'tr', 'bl', 'br']; + + //we want to round all the corners _except_ the opposite one. + var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition); + corners.remove(corner); + + return corners.join(" "); + }, + + CLASS_NAME: "OpenLayers.Popup.AnchoredBubble" +}); +/** +* @class +*/ +OpenLayers.Control = Class.create(); +OpenLayers.Control.prototype = { + + /** this gets set in the addControl() function in OpenLayers.Map + * @type OpenLayers.Map */ + map: null, + + /** @type DOMElement */ + div: null, + + /** @type OpenLayers.Pixel */ + position: null, + + /** + * @constructor + */ + initialize: function (options) { + Object.extend(this, options); + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns A reference to the DIV DOMElement containing the control + * @type DOMElement + */ + draw: function (px) { + if (this.div == null) { + this.div = OpenLayers.Util.createDiv(); + } + if (px != null) { + this.position = px.copyOf(); + } + this.moveTo(this.position); + return this.div; + }, + + /** + * @param {OpenLayers.Pixel} px + */ + moveTo: function (px) { + if ((px != null) && (this.div != null)) { + this.div.style.left = px.x + "px"; + this.div.style.top = px.x + "px"; + } + }, + + /** + */ + destroy: function () { + // eliminate circular references + this.map = null; + }, + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Control" +}; +// @require: OpenLayers/Control.js +OpenLayers.Control.MouseDefaults = Class.create(); +OpenLayers.Control.MouseDefaults.prototype = + Object.extend( new OpenLayers.Control(), { + + initialize: function() { + OpenLayers.Control.prototype.initialize.apply(this, arguments); + }, + + draw: function() { + this.map.events.register( "dblclick", this, this.defaultDblClick ); + this.map.events.register( "mousedown", this, this.defaultMouseDown ); + this.map.events.register( "mouseup", this, this.defaultMouseUp ); + this.map.events.register( "mousemove", this, this.defaultMouseMove ); + this.map.events.register( "mouseout", this, this.defaultMouseOut ); + }, + + /** + * @param {Event} evt + */ + defaultDblClick: function (evt) { + var newCenter = this.map.getLonLatFromScreenPx( evt.xy ); + this.map.setCenter(newCenter, this.map.zoom + 1); + }, + + /** + * @param {Event} evt + */ + defaultMouseDown: function (evt) { + this.mouseDragStart = evt.xy.copyOf(); + if (evt.shiftKey) { + this.map.div.style.cursor = "crosshair"; + this.zoomBox = OpenLayers.Util.createDiv('zoomBox', + this.mouseDragStart, + null, + null, + "absolute", + "2px solid red"); + this.zoomBox.style.backgroundColor = "white"; + this.zoomBox.style.filter = "alpha(opacity=50)"; // IE + this.zoomBox.style.opacity = "0.50"; + this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; + this.map.viewPortDiv.appendChild(this.zoomBox); + } else { + this.map.div.style.cursor = "move"; + } + Event.stop(evt); + }, + + /** + * @param {Event} evt + */ + defaultMouseMove: function (evt) { + if (this.mouseDragStart != null) { + if (this.zoomBox) { + var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x); + var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y); + this.zoomBox.style.width = deltaX+"px"; + this.zoomBox.style.height = deltaY+"px"; + if (evt.xy.x < this.mouseDragStart.x) { + this.zoomBox.style.left = evt.xy.x+"px"; + } + if (evt.xy.y < this.mouseDragStart.y) { + this.zoomBox.style.top = evt.xy.y+"px"; + } + } else { + var deltaX = this.mouseDragStart.x - evt.xy.x; + var deltaY = this.mouseDragStart.y - evt.xy.y; + var size = this.map.getSize(); + var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, + size.h / 2 + deltaY); + var newCenter = this.map.getLonLatFromScreenPx( newXY ); + this.map.setCenter(newCenter); + this.mouseDragStart = evt.xy.copyOf(); + } + } + }, + + /** + * @param {Event} evt + */ + defaultMouseUp: function (evt) { + if (this.zoomBox) { + var start = this.map.getLonLatFromScreenPx( this.mouseDragStart ); + var end = this.map.getLonLatFromScreenPx( evt.xy ); + var top = Math.max(start.lat, end.lat); + var bottom = Math.min(start.lat, end.lat); + var left = Math.min(start.lon, end.lon); + var right = Math.max(start.lon, end.lon); + var bounds = new OpenLayers.Bounds(left, bottom, right, top); + var zoom = this.map.getZoomForExtent(bounds); + this.map.setCenter(new OpenLayers.LonLat( + (start.lon + end.lon) / 2, + (start.lat + end.lat) / 2 + ), zoom); + this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); + this.zoomBox = null; + } + this.mouseDragStart = null; + this.map.div.style.cursor = "default"; + }, + + defaultMouseOut: function (evt) { + if (this.mouseDragStart != null + && OpenLayers.Util.mouseLeft(evt, this.map.div)) { + this.defaultMouseUp(evt); + } + } +}); + +// @require: OpenLayers/Control.js + +OpenLayers.Control.KeyboardDefaults = Class.create(); +OpenLayers.Control.KeyboardDefaults.prototype = + Object.extend( new OpenLayers.Control(), { + + initialize: function() { + OpenLayers.Control.prototype.initialize.apply(this, arguments); + }, + + draw: function() { + Event.observe(document, 'keypress', this.defaultKeyDown.bind(this.map)); + }, + + /** + * @param {Event} evt + */ + defaultKeyDown: function (evt) { + var i = 0; + switch(evt.keyCode) { + case Event.KEY_LEFT: + var resolution = this.getResolution(); + var center = this.getCenter(); + this.setCenter( + new OpenLayers.LonLat(center.lon - (resolution * 50), + center.lat) + ); + Event.stop(evt); + break; + case Event.KEY_RIGHT: + var resolution = this.getResolution(); + var center = this.getCenter(); + this.setCenter( + new OpenLayers.LonLat(center.lon + (resolution * 50), + center.lat) + ); + Event.stop(evt); + break; + case Event.KEY_UP: + var resolution = this.getResolution(); + var center = this.getCenter(); + this.setCenter( + new OpenLayers.LonLat(center.lon, + center.lat + (resolution * 50)) + ); + Event.stop(evt); + break; + case Event.KEY_DOWN: + var resolution = this.getResolution(); + var center = this.getCenter(); + this.setCenter( + new OpenLayers.LonLat(center.lon, + center.lat - (resolution * 50)) + ); + Event.stop(evt); + break; + } + } + +}); +// @require: OpenLayers/Control.js +// +// default zoom/pan controls +// +OpenLayers.Control.PanZoom = Class.create(); +OpenLayers.Control.PanZoom.X = 4; +OpenLayers.Control.PanZoom.Y = 4; +OpenLayers.Control.PanZoom.prototype = + Object.extend( new OpenLayers.Control(), { + + /** @type Array(...) */ + buttons: null, + + initialize: function() { + OpenLayers.Control.prototype.initialize.apply(this, arguments); + this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X, + OpenLayers.Control.PanZoom.Y); + }, + + /** + * @param {OpenLayers.Pixel} px + */ + draw: function(px) { + // initialize our internal div + OpenLayers.Control.prototype.draw.apply(this, arguments); + px = this.position; + + // place the controls + this.buttons = new Array(); + + var sz = new OpenLayers.Size(18,18); + var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y); + + this._addButton("panup", "north-mini.png", centered, sz); + px.y = centered.y+sz.h; + this._addButton("panleft", "west-mini.png", px, sz); + this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz); + this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz); + this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz); + this._addButton("zoomworld", "zoom-world-mini.png", centered.add(0, sz.h*4+5), sz); + this._addButton("zoomout", "zoom-minus-mini.png", centered.add(0, sz.h*5+5), sz); + return this.div; + }, + _addButton:function(id, img, xy, sz) { + var imgLocation = OpenLayers.Util.getImagesLocation() + img; + // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz); + var btn = OpenLayers.Util.createAlphaImageDiv( + "OpenLayers_Control_PanZoom_" + id, + xy, sz, imgLocation, "absolute"); + + //we want to add the outer div + this.div.appendChild(btn); + + btn.onmousedown = this.buttonDown.bindAsEventListener(btn); + btn.ondblclick = this.doubleClick.bindAsEventListener(btn); + btn.action = id; + btn.map = this.map; + + //we want to remember/reference the outer div + this.buttons.push(btn); + return btn; + }, + + doubleClick: function (evt) { + Event.stop(evt); + }, + + buttonDown: function (evt) { + switch (this.action) { + case "panup": + var resolution = this.map.getResolution(); + var center = this.map.getCenter(); + this.map.setCenter( + new OpenLayers.LonLat(center.lon, + center.lat + (resolution * 50)) + ); + break; + case "pandown": + var resolution = this.map.getResolution(); + var center = this.map.getCenter(); + this.map.setCenter( + new OpenLayers.LonLat(center.lon, + center.lat - (resolution * 50)) + ); + break; + case "panleft": + var resolution = this.map.getResolution(); + var center = this.map.getCenter(); + this.map.setCenter( + new OpenLayers.LonLat(center.lon - (resolution * 50), + center.lat) + ); + break; + case "panright": + var resolution = this.map.getResolution(); + var center = this.map.getCenter(); + this.map.setCenter( + new OpenLayers.LonLat(center.lon + (resolution * 50), + center.lat) + ); + break; + case "zoomin": this.map.zoomIn(); break; + case "zoomout": this.map.zoomOut(); break; + case "zoomworld": this.map.zoomExtent(); break; + } + Event.stop(evt); + }, + destroy: function() { + OpenLayers.Control.prototype.destroy.apply(this, arguments); + for(i=0; i