OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer.Markers, { drawMarker: function(marker) { var px = this.map.getLayerPxFromLonLat(marker.lonlat); if (px == null) { marker.display(false);} else { var markerImg = marker.draw(px); var iconUrl = markerImg.childNodes[0].src; var iconWidth = parseInt(markerImg.style.width); var iconHeight = parseInt(markerImg.style.height); var iconZIndex = markerImg.childNodes[0].style.zIndex; if (marker.text && marker.text.length != 0) { var textMarker = document.createElement('DIV'); textMarker.innerText = marker.text; textMarker.style.width = iconWidth; textMarker.style.height = iconHeight; textMarker.style.color = marker.color; textMarker.style.paddingTop = marker.paddingTop; textMarker.style.fontFamily = marker.fontFamily; textMarker.style.fontSize = marker.fontSize; textMarker.style.fontStyle = marker.fontStyle; textMarker.style.zIndex = iconZIndex + 1; textMarker.style.left = (iconWidth - marker.text.length * marker.fontSize) / 2 + 2; textMarker.style.position = 'absolute'; textMarker.style.overflow = 'hidden'; textMarker.style.cursor = 'normal'; markerImg.appendChild(textMarker);}
if (!marker.drawn) { this.div.appendChild(markerImg); marker.drawn = true;}
}
}
}); OpenLayers.Marker.GeoMarker = OpenLayers.Class(OpenLayers.Marker, { id: null, uniqueId: null, extra: null, text: '', paddingTop: 0, fontSize: 10, color: 'black', fontFamily: 'verdana', fontStyle: 'normal', popup: null, hoverText: null, popupX: null, popupY: null, popupVisible: null, popupWidth: null, popupHeight: null, popupHasCloseButton: null, popupAutoPan: null, popupDelay: null, popupHideTimer: null, initialize: function(id, lonlat, icon) { this.id = id; this.lonlat = lonlat; var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); if (this.icon == null) { this.icon = newIcon;} else { this.icon.url = newIcon.url; this.icon.size = newIcon.size; this.icon.offset = newIcon.offset; this.icon.calculateOffset = newIcon.calculateOffset;}
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);}, initializePopup: function(map) { if (this.icon.size == null) { this.popup = new Popup(this.popupJson, null).element;} else { this.popup = new Popup(this.popupJson, this.icon).element;}
this.popup.lonlat = this.lonlat; this.popup.isMarkerHoverPopup = true; this.popupVisible = this.popupJson.visibility; map.addPopup(this.popup); if (!this.popupVisible) { this.popup.hide();}
if (!this.popupVisible) { this.popup.events.register('mouseover', this, function(evt) { clearTimeout(this.hideTimer);}); this.popup.events.register('mouseout', this, function(evt) { this.hidePopup(map);}); this.popup.hide();}
}, showPopup: function() { if (!this.popupVisible)
this.showTimer = setTimeout(Function.createDelegate(this, function() { if (this.popup && this.popup.div) { if (!this.popup.map) this.popup.map = this.map; this.popup.show(); if (typeof (OnPopupShowing) != 'undefined' && OnPopupShowing != null) { OnPopupShowing.call(this.popup, { isLeft: this.popup.left, isTop: this.popup.top });}
}
}), this.popupDelay);}, hidePopup: function() { if (!this.popupVisible) { if (this.showTimer) { window.clearTimeout(this.showTimer);}
this.hideTimer = setTimeout(Function.createDelegate(this, function() { if (this.popup && this.popup.div) { if (!this.popup.map) this.popup.map = this.map; this.popup.hide();}
}), 500);}
}, movePopup: function(px) { if (this.popup && this.popup.div) { if (!this.popup.map) this.popup.map = this.map; this.popup.lonlat = this.map.getLonLatFromLayerPx(px); this.popup.updatePosition();}
}, CLASS_NAME: "OpenLayers.Marker.GeoMarker"
}); OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control.LayerSwitcher, { onLayerChanged: function(newLayer) { }, onInputClick: function(e) { if (!this.inputElem.disabled) { if (this.inputElem.type == "radio") { this.inputElem.checked = true; this.layer.map.setBaseLayer(this.layer); if (this.layerSwitcher.onLayerChanged != "") { this.layerSwitcher.onLayerChanged(this.layer.map.baseLayer.name);}
} else { this.inputElem.checked = !this.inputElem.checked; this.layerSwitcher.updateMap();}
}
OpenLayers.Event.stop(e);}
}); OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control.MousePosition, { showType: 'lonlat', numdigits: 5, formatOutput: function(lonLat) { var digits = parseInt(this.numdigits); var newHtml = ''; if (this.showType == 'dms') { newHtml = this.prefix + this.getDms(lonLat.lon.toFixed(digits)) + ', ' + this.getDms(lonLat.lat.toFixed(digits)) + this.suffix;} else if (this.showType == 'lonlat') { newHtml = this.prefix + lonLat.lon.toFixed(digits) + this.separator + lonLat.lat.toFixed(digits) + this.suffix;} else if (this.showType == 'latlon') { newHtml = this.prefix + lonLat.lat.toFixed(digits) + this.separator + lonLat.lon.toFixed(digits) + this.suffix;}
return newHtml;}, getDms: function(value) { var absDdValue = Math.abs(value); var degrees; if (value >= 0) { degrees = Math.floor(value);} else { degrees = Math.ceil(value);}
var tmpMinute = this.calculateDmsFactor(absDdValue); var tmpSecond = this.calculateDmsFactor(tmpMinute); return degrees + "° " + parseInt(tmpMinute) + "' " + parseInt(tmpSecond) + "''";}, calculateDmsFactor: function(value) { var decimals = 10000; return Math.round(((value - Math.floor(value)) * 60 * decimals)) / decimals;}
}); OpenLayers.Control.Logo = OpenLayers.Class(OpenLayers.Control.Attribution, { innerHTML: null, initialize: function(url) { var arVersion = navigator.appVersion.split("MSIE"); var version = parseFloat(arVersion[1]); if (version == 6) { this.innerHTML = '
'
} else { this.innerHTML = '
';}
}, updateAttribution: function() { if (this.map && this.innerHTML) { this.div.style.right = "10px"; this.div.style.bottom = "10px"; this.div.innerHTML = this.innerHTML;}
}, CLASS_NAME: "OpenLayers.Control.Logo"
}); OpenLayers.Map = OpenLayers.Class(OpenLayers.Map, { minZoomLevel: 0, setCenter: function(lonlat, zoom, dragging, forceZoomChange) { if (zoom == null) { zoom = this.getZoom();}
if (this.restrictedExtent) { var restrictedZoom = this.getZoomForExtent(this.restrictedExtent); if (zoom < restrictedZoom) { zoom = restrictedZoom;}
}
if (zoom < this.minZoomLevel) { zoom = this.minZoomLevel;}
this.moveTo(lonlat, zoom, { 'dragging': dragging, 'forceZoomChange': forceZoomChange, 'caller': 'setCenter'
});}, destroyShallow: function() { if (!this.unloadDestroy) { return false;}
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); this.unloadDestroy = null; if (this.updateSizeDestroy) { OpenLayers.Event.stopObserving(window, 'resize', this.updateSizeDestroy);} else { this.events.unregister("resize", this, this.updateSize);}
this.paddingForPopups = null; if (this.eventListeners) { this.events.un(this.eventListeners); this.eventListeners = null;}
this.events.destroy(); this.events = null;}
}); OpenLayers.Layer.Markers.DragableMarkers = OpenLayers.Class(OpenLayers.Layer.Markers, { CLASS_NAME: "OpenLayers.Layer.Markers.DragMarkers", isDragging: false, selectedMarker: null, crossMarker: null, bouncingTimer: null, bouncingMarker: null, wireDragEvents: function() { if (this.dragMode == 'none') { return;}
var size = new OpenLayers.Size(16, 16); var offset = new OpenLayers.Pixel(-(size.w / 2), -(size.h / 2)); var icon = new OpenLayers.Icon(this.rootPath + 'theme/default/img/cross.gif', size, offset); this.crossMarker = new OpenLayers.Marker(new OpenLayers.LonLat(0, 0), icon); this.crossMarker.isShadow = true; this.addMarkerCore(this.crossMarker); this.crossMarker.display(false); this.events.includeXY = true; this.map.events.register('mousemove', this, function(e) { if (this.isDragging && this.selectedMarker != null) { var newXY = e.xy; var targetXY = this.map.getLayerPxFromViewPortPx(newXY); var markerXY = new OpenLayers.Pixel(targetXY.x, targetXY.y - 15); this.selectedMarker.moveTo(markerXY); this.crossMarker.moveTo(targetXY); this.crossMarker.display(true); if (this.selectedMarker.popup) { this.selectedMarker.hidePopup();}
}
}); this.map.events.register('mouseup', this, function(e) { this.isDragging = false; if (this.selectedMarker != null) { this.bouncingMarker = this.selectedMarker; var hoverPopup = this.selectedMarker.popup; this.selectedMarker = null; var bouncingHandler = function() { var marker = this.marker; var layer = this.layer; var currentXY = layer.map.getLayerPxFromLonLat(marker.lonlat); var targetXY = this.targetXY; var timer = this.timer; if (currentXY.y < targetXY.y) { currentXY.y += 1; marker.moveTo(currentXY);} else { marker.moveTo(targetXY); this.layer.bouncingMarker = null; window.clearInterval(layer.bouncingTimer); layer.bouncingTimer = null; if (this.layer.draggedEvent) { var markerId = marker.id; var lon = marker.lonlat.lon; var lat = marker.lonlat.lat; this.layer.map.isMarkerDragging = false; __doPostBack(this.layer.map.uniqueId, 'MARKERDRAGGED^' + layer.id + '^' + markerId + '^' + lon + '^' + lat);}
}
}
var getDelegate = function(sender, handler) { return function() { handler.apply(sender, arguments);}
}
var targetXY = this.map.getLayerPxFromLonLat(this.crossMarker.lonlat); this.bouncingMarker.movePopup(targetXY); this.bouncingTimer = window.setInterval(getDelegate({ marker: this.bouncingMarker, layer: this, targetXY: targetXY }, bouncingHandler), 5); this.crossMarker.display(false);}
});}, addMarker: function(marker) { this.addMarkerCore(marker); if (this.dragMode == 'drag') { marker.events.register('mousedown', { layer: this, selectedMarker: marker }, function(e) { this.layer.map.isMarkerDragging = true; this.layer.removeBouncingAnimation(this.layer); this.layer.isDragging = true; this.layer.selectedMarker = this.selectedMarker; this.layer.selectedMarker.map = this.layer.map; this.layer.crossMarker.map = this.layer.map; this.layer.crossMarker.moveTo(this.layer.getViewPortPxFromLonLat(this.selectedMarker.lonlat)); OpenLayers.Event.stop(e);});}
}, addMarkerCore: function(marker) { OpenLayers.Layer.Markers.prototype.addMarker.apply(this, arguments);}, removeBouncingAnimation: function(layer) { if (layer.bouncingTimer) { window.clearTimeout(layer.bouncingTimer);}
if (layer.bouncingMarker) { layer.bouncingMarker = null;}
}
}); OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile.Image, { renderTile: function() { if (this.imgDiv == null) { this.initImgDiv();}
this.imgDiv.viewRequestID = this.layer.map.viewRequestID; if (this.layer.url instanceof Array) { this.imgDiv.urls = this.layer.url.slice();}
this.url = this.layer.getURL(this.bounds); if (this.url) { this.url += '&ZOOM=' + this.layer.map.getZoom();}
OpenLayers.Util.modifyDOMElement(this.frame, null, this.position, this.size); var imageSize = this.layer.getImageSize(); if (this.layerAlphaHack) { OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, null, null, imageSize, this.url);} else { OpenLayers.Util.modifyDOMElement(this.imgDiv, null, null, imageSize); this.imgDiv.src = this.url;}
return true;}
}); OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.RegularPolygon, { isMoved: false, down: function(evt) { this.moved = false; this.fixedRadius = !!(this.radius); var maploc = this.map.getLonLatFromPixel(evt.xy); this.origin = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat); if (!this.fixedRadius || this.irregular) { this.radius = this.map.getResolution();}
if (this.persist) { this.clear();}
this.feature = new OpenLayers.Feature.Vector(); this.createGeometry(); this.layer.addFeatures([this.feature], { silent: true }); this.layer.drawFeature(this.feature, this.style);}, move: function(evt) { this.moved = true; var maploc = this.map.getLonLatFromPixel(evt.xy); var point = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat); if (this.irregular) { var ry = Math.sqrt(2) * Math.abs(point.y - this.origin.y) / 2; this.radius = Math.max(this.map.getResolution() / 2, ry);} else if (this.fixedRadius) { this.origin = point;} else { this.calculateAngle(point, evt); this.radius = Math.max(this.map.getResolution() / 2, point.distanceTo(this.origin));}
this.modifyGeometry(); if (this.irregular) { var dx = point.x - this.origin.x; var dy = point.y - this.origin.y; var ratio; if (dy == 0) { ratio = dx / (this.radius * Math.sqrt(2));} else { ratio = dx / dy;}
this.feature.geometry.resize(1, this.origin, ratio); this.feature.geometry.move(dx / 2, dy / 2);}
this.layer.drawFeature(this.feature, this.style);}, up: function(evt) { if (!this.moved) { this.layer.eraseFeatures([this.feature]);}
this.finalize();}
}); OpenLayers.Popup.Anchored = OpenLayers.Class(OpenLayers.Popup.Anchored, { top: null, left: null, calculateNewPx: function(px) { var newPx = px.offset(this.anchor.offset); var size = this.size || this.contentSize; var top = (this.relativePosition.charAt(0) == 't'); newPx.y += (top) ? -size.h : this.anchor.size.h; var left = (this.relativePosition.charAt(1) == 'l'); newPx.x += (left) ? -size.w : this.anchor.size.w; this.top = top; this.left = left; return newPx;}
}); OpenLayers.Layer.VirtualEarth = OpenLayers.Class(OpenLayers.Layer.VirtualEarth, { loadMapObject: function() { var veDiv = OpenLayers.Util.createDiv(this.name); var sz = this.map.getSize(); veDiv.style.width = sz.w + "px"; veDiv.style.height = sz.h + "px"; this.div.appendChild(veDiv); try { this.mapObject = new VEMap(this.name);} catch (e) { }
if (this.mapObject != null) { try { this.mapObject.LoadMap(null, null, this.type, true); this.mapObject.AttachEvent("onmousedown", function() { return true;}); this.mapObject.SetAnimationEnabled(false);} catch (e) { }
this.mapObject.HideDashboard();}
if (!this.mapObject || !this.mapObject.vemapcontrol || !this.mapObject.vemapcontrol.PanMap || (typeof this.mapObject.vemapcontrol.PanMap != "function")) { this.dragPanMapObject = null;}
}
}); OpenLayers.Layer.Google = OpenLayers.Class(OpenLayers.Layer.Google, { setMap: function(map) { OpenLayers.Layer.EventPane.prototype.setMap.apply(this, arguments); if (this.type != null) { this.mapObject.setMapType(this.type); this.map.events.register("moveend", this, this.setMapType);}
}
}); OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile.Image, { destroy: function() { if (this.imgDiv != null) { if (this.layerAlphaHack) { OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0].id);}
OpenLayers.Event.stopObservingElement(this.imgDiv.id); if (this.imgDiv.parentNode == this.frame) { this.frame.removeChild(this.imgDiv); this.imgDiv.map = null;}
this.imgDiv.urls = null; this.imgDiv.src = OpenLayers.Util.getImagesLocation() + "blank.gif";}
this.imgDiv = null; if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) { this.layer.div.removeChild(this.frame);}
this.frame = null; if (this.backBufferTile) { this.backBufferTile.destroy(); this.backBufferTile = null;}
this.layer.events.unregister("loadend", this, this.resetBackBuffer); OpenLayers.Tile.prototype.destroy.apply(this, arguments);}
}); OpenLayers.Icon = OpenLayers.Class(OpenLayers.Icon, { initialize:function(url,size,offset,calculateOffset){ this.url=url; this.size=(size)?size:new OpenLayers.Size(20,20); this.offset=offset?offset:new OpenLayers.Pixel(-(this.size.w/2),-(this.size.h/2)); this.calculateOffset=calculateOffset; var id=OpenLayers.Util.createUniqueID("OL_Icon_"); this.size = size; this.imageDiv=OpenLayers.Util.createAlphaImageDiv(id);}
});
var LoadingImageUrl = '/theme/default/img/loading.gif'; var MarkerOverlayEventPrefix = 'MARKEROVERLAYCLICK'; var TopZIndex = 100000; var unitLengthsForExtent = { 'degrees': 180, 'm': 20001364.487263177, 'ft': 65621309.99999999 }; var Class = { Create: function() { return function() { this.initialize.apply(this, arguments);}
}, Extent: function(destination, source) { for (var key in source) { destination[key] = source[key];}
return destination;}
}; function GetShorterGeographyUnit(unit) { switch (unit) { case 'Feet': return 'ft'; case 'Meter': return 'm'; default: return 'degrees'
}
}
function GetMaxExtentByUnits(unit) { var unitLength = unitLengthsForExtent[unit]; if (unitLength)
return new OpenLayers.Bounds(unitLength * -1, unitLength * -1, unitLength, unitLength);}
function ConvertJsonToBounds(json) { return new OpenLayers.Bounds(json.left, json.bottom, json.right, json.top);}
function ConvertJsonToLonLat(json) { return new OpenLayers.LonLat(json.x, json.y);}
function ConvertJsonToIcon(json, imgRootPath) { var size; if (json.w == 0 && json.h == 0) { size = null;} else { size = new OpenLayers.Size(json.w, json.h);}
if (json.url == '') { json.url = imgRootPath + 'theme/default/img/marker_blue.gif';}
var icon = new OpenLayers.Icon(json.url, size); if (size) { icon.offset = new OpenLayers.Pixel(CalculateOffset(json.ox, size.w), CalculateOffset(json.oy, size.h));}
return icon;}
function ConvertJsonToSize(json) { if (json.w != 0 && json.h != 0) { return new OpenLayers.Size(json.w, json.h);} else { return null;}
}
function CalculateOffset(offset, width) { if (offset == NaN || offset.toString().toUpperCase() == 'NAN') { return -width / 2;} else { return offset;}
}
function ConvertBoundsToString(bounds) { return (bounds.left + ',' + bounds.bottom + ',' + bounds.right + ',' + bounds.top);}
function ConvertLonLatToString(lonlat) { return lonlat.lon + ',' + lonlat.lat;}
function CreateImageNode(id, infos, parentW, parentH, localUrl) { var w = infos.w == 0 ? 128 : infos.w; var h = infos.h == 0 ? 15 : infos.h; var url = infos.uri; var img = NewDomNode('IMG'); img.style.position = 'absolute'; img.style.zIndex = TopZIndex; img.style.width = w + 'px'; img.style.height = h + 'px'; img.style.left = ((parentW / 2) - (w / 2)) + 'px'; img.style.top = ((parentH / 2) - (h / 2)) + 'px'; img.style.display = 'none'; img.id = id; img.src = (!url || url == '') ? localUrl : url; return img;}
function HideContextMenus() { if (CurrentContextMenu) { CurrentContextMenu.display(false);}
}
function NewDomNode(tagName) { return document.createElement(tagName);}
function GetDomNode(id) { return document.getElementById(id);}
function CheckObjectExists(obj) { if (obj && obj != 'undefined' && obj != undefined) { return true;} else { return false;}
}
function IsBoundsValidated(extent) { return (extent.left != null
&& extent.bottom != null
&& extent.right != null
&& extent.top != null);}
function AddMarkersByAjax(map, json) { var markerOverlays = eval('(' + json + ')'); if (markerOverlays && markerOverlays.length != 0) { for (var i = 0; i < markerOverlays.length; i++) { var layer = map.getLayer(markerOverlays[i].id); if (layer) { RemoveMarkerPopups(layer); var markersCount = layer.markers.length; for (var j = 0; j < markersCount; j++) { var removeMarker = layer.markers[0]; layer.removeMarker(removeMarker); removeMarker.destroy();}
var hasCtx = false; var rootPath = layer.rootPath; if (markerOverlays[i].markers && markerOverlays[i].markers.length != 0) { for (var j = 0; j < markerOverlays[i].markers.length; j++) { var markerJson = markerOverlays[i].markers[j]; var markerCreator = new Marker(markerJson, rootPath); markerCreator.overlayId = layer.id; markerCreator.mapUid = map.uniqueId; markerCreator.mapCid = map.clientId; markerCreator.currentZoom = map.getZoom(); if (markerJson.contextMenu && markerJson.contextMenu != 'undefined' && markerJson.contextMenu.items.length != 0) { markerCreator.setContextMenu(markerJson); hasCtx = true;}
var marker = markerCreator.element; if (markerJson.popup && markerJson.popup != 'undefined' && markerJson.popup.html && markerJson.popup.html != '') { marker.popupJson = markerJson.popup; marker.popupDelay = markerJson.popupdelay; marker.initializePopup(map); marker.events.register('mouseover', marker, function(evt) { this.showPopup();}); marker.events.register('mouseout', marker, function(evt) { this.hidePopup();});}
marker = GetHookedClickEventMarker(marker, layer); layer.addMarker(marker); if (hasCtx) { layer.div.oncontextmenu = function() { return false;};} else { layer.div.oncontextmenu = null;}
}
}
}
}
}
}
function RemoveMarkerPopups(layer) { for (var i = 0; i < layer.markers.length; i++) { if (layer.markers[i].popup) { var removePopup = layer.markers[i].popup; layer.map.removePopup(removePopup); removePopup.destroy();}
}
}
function GetHookedClickEventMarker(marker, markerOverlay) { marker.parentId = markerOverlay.id; if (markerOverlay.click) { marker.icon.imageDiv.style.cursor = 'pointer'; marker.events.register('click', marker, function(evt) { __doPostBack(this.map.uniqueId, MarkerOverlayEventPrefix + '^' + this.parentId + '^' + this.id);});}
return marker;}
function HasObject(array, value) { for (var i = 0; i < array.length; i++) { if (array[i] == value) { return true;}
}
return false;}
function CreateAllMaps() { for (var i = 0; i < MultiMap.length; i++) { eval('var parser = parser' + MultiMap[i]); parser.createMap();}
}
function CleanMap(mapId){ var map = eval(mapId); if(map){ map.Destory();}
}
function CleanAllMaps(){ for (var i = 0; i < MultiMap.length; i++) { CleanMap(MultiMap[i]);}
}
function keepsession() { var request = OpenLayers.Request.issue({ url: 'session_GeoResource.axd' }); window.setTimeout("keepsession()", 900000);}
var Overlay = Class.Create(); var SphericalOverlay = Class.Create(); var WmsOverlay = Class.Create(); var LayerOverlay = Class.Create(); var MarkerOverlay = Class.Create(); var SimpleMarkerOverlay = Class.Create(); var Control = Class.Create(); var Popup = Class.Create(); var Marker = Class.Create(); Class.Extent(Overlay.prototype, { id: null, options: {}, element: null, initialize: function(json) { this.options = {}; this.setCommonOptions(json);}, setCommonOptions: function(json) { this.id = json.Id; this.name = json.name; if (this.name == 'undefined' || !this.name) { this.name = '';}
this.options.isBaseLayer = json.isBaseLayer; this.options.visibility = json.visibility; this.options.initVisibility = json.visibility; this.options.name = this.name; this.options.opacity = json.opacity; this.options.displayInLayerSwitcher = json.displayInLayerSwitcher;}
}); Class.Extent(SphericalOverlay.prototype, Overlay.prototype); Class.Extent(SphericalOverlay.prototype, { json: null, type: null, overlayType: null, initialize: function(json) { this.json = json; this.setCommonOptions(json); this.type = json.otype; this.options.type = eval(json.type); this.options.sphericalMercator = true; this.options.maxResolution = 156543.0339; this.options.maxExtent = new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34);}, createGoogleOverlay: function() { this.element = new OpenLayers.Layer.Google(this.name, this.options);}, createVirtualEarthOverlay: function() { this.element = new OpenLayers.Layer.VirtualEarth(this.name, this.options);}, createYahooOverlay: function() { this.element = new OpenLayers.Layer.Yahoo(this.name, this.options);}, createCustomerOverlay: function() { this.element = this.getCustomerOverlay(this.json);}, getCustomerOverlay: function(json) { return null }, createOverlay: function() { switch (this.type.toUpperCase()) { case "GOOGLE": this.createGoogleOverlay(); break; case "VIRTUALEARTH": this.createVirtualEarthOverlay(); break; case "YAHOO": this.createYahooOverlay(); break; default: this.createCustomerOverlay(); break;}
this.element.id = this.id;}
}); Class.Extent(WmsOverlay.prototype, Overlay.prototype); Class.Extent(WmsOverlay.prototype, { url: null, params: {}, pageName: null, initialize: function(json, pageName) { this.params = {}; this.setCommonOptions(json); if (!this.url) { this.url = json.uris;}
this.pageName = pageName; if (json.buffer && json.buffer != 'undefined') { this.options.buffer = json.buffer;} else { this.options.buffer = 0;}
this.options.ratio = 1; this.options.displayOutsideMaxExtent = true; this.options.singleTile = (parseInt(json.singleTile) == 1); this.options.tileSize = new OpenLayers.Size(json.w, json.h); this.options.transitionEffect = json.transitionEffect; this.setAlphaChanel(); this.setParameters(json);}, setResolutions: function(resolutions) { this.options.resolutions = resolutions;}, setAlphaChanel: function() { var versionString = navigator.appVersion.split("MSIE"); var version = parseFloat(versionString[1]); if (version == 6) { this.options.alpha = true;}
}, setProjection: function(srs) { if (srs && srs != 'undefined') { this.element.projection = srs;}
}, setParameters: function(json) { this.setCustomerParams(json);}, createWms: function() { this.element = new OpenLayers.Layer.WMS(this.name, this.url, this.params, this.options); this.element.id = this.id;}, hookLoadingImage: function(mapClientId) { this.element.mapClientId = mapClientId; this.element.events.register('loadstart', this.element, function(evt) { var loadingDiv = GetDomNode('loading' + this.mapClientId); if (loadingDiv) { loadingDiv.style.display = 'block';}
}); this.element.events.register('loadend', this.element, function(evt) { var loadingDiv = GetDomNode('loading' + this.mapClientId); if (loadingDiv) { loadingDiv.style.display = 'none';}
});}, setCustomerParams: function(json) { for (var key in json.parameters) { if (key.toUpperCase() == 'SRS') { this.options.projection = new OpenLayers.Projection(json.parameters[key.toString()]);} else { this.params[key] = json.parameters[key];}
}
}, setDefaultParams: function(json) { this.params.overlayid = escape(json.Id); this.params.format = json.imageFormat; this.params.cacheid = escape(json.clientCache.cacheId); this.params.pageName = escape(this.pageName); this.params.exceptions = null; this.params.request = null; this.params.service = null; this.params.version = null; this.params.style = null;}
}); Class.Extent(LayerOverlay.prototype, WmsOverlay.prototype); Class.Extent(LayerOverlay.prototype, { url: 'tile_GeoResource.axd', setParameters: function(json) { if (json.singleThread) { this.url = 'singletile_GeoResource.axd';}
WmsOverlay.prototype.setParameters.apply(this, arguments); this.setDefaultParams(json);}
}); Class.Extent(MarkerOverlay.prototype, Overlay.prototype); Class.Extent(MarkerOverlay.prototype, { element: null, createMarkerOverlay: function() { this.element = new OpenLayers.Layer.Markers(this.name, this.options); this.element.id = this.id;}, hookEvent: function(flag) { if (flag) { this.element.click = true;}
}
}); Class.Extent(SimpleMarkerOverlay.prototype, MarkerOverlay.prototype); Class.Extent(SimpleMarkerOverlay.prototype, { createMarkerOverlay: function() { this.element = new OpenLayers.Layer.Markers.DragableMarkers(this.name, this.options); this.element.id = this.id; this.element.isSimpleMarkerOverlay = true;}, setOptions: function(json) { this.options.dragMode = json.dragMode; this.options.draggedEvent = json.draggedEvent;}, hookMarkersJson: function(markersJson) { this.element.markersJson = markersJson;}, hookEvent: function(flag) { if (flag) { this.element.click = true;}
}
}); Class.Extent(Control.prototype, { element: null, initialize: function(name, options) { if (options.enabled) { this.element = eval('new OpenLayers.Control.' + name + '()'); for (var key in options) { if (key != 'enabled')
this.element[key] = options[key];}
}
}
}); Class.Extent(Popup.prototype, { element: null, initialize: function(json, anchor) { var lonlat = ConvertJsonToLonLat(json.lonlat); var size = ConvertJsonToSize({ 'w': json.w, 'h': json.h }); if (json.popupType == 'NormalPopup') { this.element = new OpenLayers.Popup.Anchored(json.id, lonlat, size, json.html, anchor, json.closable); this.setBorder(json); this.setBgColor(json); this.setBgImg(json);} else if (json.popupType == 'CloudPopup') { this.element = new OpenLayers.Popup.FramedCloud(json.id, lonlat, size, json.html, anchor, json.closable); this.setAlphaChanel();} else { this.element = this.getCustomerPopup(json);}
this.element.panMapIfOutOfView = json.autopan; this.element.autoSize = json.autosize; this.setOffset(json);}, setAlphaChanel: function() { var versionString = navigator.appVersion.split("MSIE"); var version = parseFloat(versionString[1]); if (version == 6) { this.element.isAlphaImage = true;}
}, setBorder: function(json) { this.element.border = 'solid ' + json.bw + 'px ' + json.bdcolor;}, setBgColor: function(json) { if (json.bgcolor.toUpperCase == 'TRANSPARENT') { this.element.backgroundColor = ''; this.element.groupDiv.style.backgroundColor = null;} else { this.element.backgroundColor = json.bgcolor;}
}, setBgImg: function(json) { if (CheckObjectExists(json.backImg)) { this.element.div.style.backgroundImage = 'url("' + json.backImg + '")';}
}, setVisible: function(visible) { if (visible) { this.element.show();} else { this.element.hide();}
}, setOffset: function(json) { if (json.ox && json.ox != 'undefined' && json.ox != 0) { this.element.offsetX = json.ox;}
if (json.oy && json.oy != 'undefined' && json.oy != 0) { this.element.offsetY = json.oy;}
}, getCustomerPopup: function(json) { return null;}
}); Class.Extent(Marker.prototype, { element: null, overlayId: null, mapUid: null, mapCid: null, currentZoom: null, initialize: function(json, imgRootPath) { var popupJson = json.popup; var lonlat = ConvertJsonToLonLat(json.lonlat); var icon = ConvertJsonToIcon(json.img, imgRootPath); this.element = new OpenLayers.Marker.GeoMarker(json.id, lonlat, icon); if (json.opacity && json.opacity != 'undefined') { this.element.setOpacity(json.opacity);}
}, setContextMenu: function(json) { this.element.contextMenu = json.contextMenu; this.element.overlayId = this.overlayId; this.element.mapUid = this.mapUid; this.element.mapCid = this.mapCid; this.element.currentZoom = this.currentZoom; this.element.events.register('mousedown', this.element, function(evt) { if (evt && evt.button == 2) { var lonlat = this.lonlat; var target = this.CLASS_NAME + '|' + this.overlayId + '|' + this.currentZoom; HideContextMenus(); var contextMenu = new ContextMenu(this.contextMenu, lonlat, target, this.mapUid); for (var i = 0; i < this.contextMenu.items.length; i++) { contextMenu.addItem(this.contextMenu.items[i]);}
contextMenu.moveTo(evt.clientX, evt.clientY); contextMenu.display(true); document.getElementById(this.mapCid).parentNode.appendChild(contextMenu.div); CurrentContextMenu = contextMenu; return false;}
});}
});
var MultiMap = new Array(); var CurrentContextMenu = null; var CircleSide = 32; var DefaultLogoUrl = 'logo_GeoResource.axd'; var TransparentStyle = { 'fillOpacity': 0, 'strokeOpacity': 0 }; var IconPath = 'theme/default/img/'; var CssPath = 'theme/default/style.css'; var LoadingImageUrl = 'theme/default/img/loading.gif'; var WmsUri = "tile_GeoResource.axd"; var PopupStyle = OpenLayers.Class(OpenLayers.Popup.FramedCloud, { 'autoSize': true }); var MaxNum = 1000000000; var MinNum = -1000000000; var MinScale = 442943842.5; var CurrentMapClientId = ''; var SelectedFeature = null; var PointRadius = 6
var mapParser = Class.Create(); Class.Extent(mapParser.prototype, { json: null, map: null, pageName: null, markerOverlayIds: null, simpleMarkerOverlayIds: null, editOverlay: null, paintControls: null, load: true, initialize: function(json) { OpenLayers.ImgPath = json.rootPath + IconPath; this.json = json; this.pageName = json.pageName; this.markerOverlayIds = new Array(); this.simpleMarkerOverlayIds = new Array(); this.initFeatureStyle(); this.initMap(json);}, destroy: function() { var clientId = this.map.clientId; if (this.map && window.navigator.appName.toUpperCase() != 'NETSCAPE') { this.map.destroy(); this.map = null;}
if (this.json) { this.json = null;}
if (this.markerOverlayIds) { this.markerOverlayIds = null;}
if (document.getElementById(clientId)) { document.getElementById(clientId).innerHTML = '';}
}, initFeatureStyle: function(style) { for (var key in this.json.editOverlay.style) { OpenLayers.Feature.Vector.style['default'][key] = this.json.editOverlay.style[key];}
var selectedStyle = this.getDefaultSelectStyle(); for (var key in selectedStyle) { OpenLayers.Feature.Vector.style['select'][key] = selectedStyle[key];}
}, getDefaultSelectStyle: function() { var defaultSelectStyle = {}; defaultSelectStyle.fillColor = '#ff6500'; defaultSelectStyle.strokeColor = '#ff6500'; defaultSelectStyle.pointRadius = '6'; defaultSelectStyle.fillOpacity = '0.3'; defaultSelectStyle.strokeWidth = '1'; defaultSelectStyle.strokeOpacity = '0.6'; return defaultSelectStyle;}, initMap: function(json) { var options = { 'theme': json.rootPath + CssPath, 'numZoomLevels': 20 }; options.units = GetShorterGeographyUnit(json.units); if (options.units == 'degrees') { options.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);} else { options.maxExtent = new OpenLayers.Bounds(MinNum, MinNum, MaxNum, MaxNum);}
options.controls = []; if (json.restrictedExtent) { options.restrictedExtent = ConvertJsonToBounds(json.restrictedExtent);}
options.resolutions = json.resolutions; this.map = new OpenLayers.Map(json.cid, options); this.map.uniqueId = json.uid; this.map.clientId = json.cid; this.map.extentChanged = json.extentChanged; this.setCursor(); this.map.events.register('mouseup', this, function(e) { this.setCursor();}); if (json.onClientExtentChanged && json.onClientExtentChanged != '') { this.map.events.register('moveend', this, eval(json.onClientExtentChanged));}
this.map.events.register('moveend', this, this.extentChanged); this.map.events.register('moveend', this, this.extentChangedPostBack); this.map.events.register('move', this, function(evt) { HideContextMenus();}); this.initLoadingControl(json); if (!HasObject(MultiMap, json.cid)) { MultiMap.push(json.cid);}
this.map.click = json.click; this.map.events.register('click', this.map, function(e) { HideContextMenus();}); if (json.onClientClick && json.onClientClick != '') { this.map.events.register('click', this.map, eval(json.onClientClick));}
this.map.events.register('click', this.map, function(e) { if (this.click && !this.isMarkerDragging) { var lonlat = this.getLonLatFromViewPortPx(e.xy); __doPostBack(json.uid, 'CLICK^' + lonlat.lon + '^' + lonlat.lat);}
}); this.initDblClick(json); if (json.contextMenu && json.contextMenu != 'undefined') { this.map.contextMenu = json.contextMenu; document.getElementById(this.map.clientId).oncontextmenu = function() { return false;}; this.map.events.register('mousedown', this.map, function(evt) { HideContextMenus(); if (evt && evt.button == 2) { var lonlat = this.getLonLatFromPixel(evt.xy); var target = this.CLASS_NAME + '|' + this.id; var contextMenu = new ContextMenu(this.contextMenu, lonlat, target, this.uniqueId); for (var i = 0; i < this.contextMenu.items.length; i++) { contextMenu.addItem(this.contextMenu.items[i]);}
contextMenu.moveTo(evt.clientX, evt.clientY); contextMenu.display(true); document.getElementById(this.clientId).parentNode.appendChild(contextMenu.div); CurrentContextMenu = contextMenu;}
});}
}, initDblClick: function(json) { var dblClick = null; var dblClientClick = null; if (json.dblClick && json.dblClick != '') { dblClick = function(evt) { var lonlat = this.map.getLonLatFromViewPortPx(evt.xy); __doPostBack(json.uid, 'DBLCLICK^' + lonlat.lon + '^' + lonlat.lat);};}
if (json.onClientDoubleClick && json.onClientDoubleClick != '') { dblClientClick = eval(json.onClientDoubleClick);}
var dblClickEventHandlers = new Array(); if (dblClientClick)
dblClickEventHandlers.push({ obj: this, func: dblClientClick }); if (dblClick)
dblClickEventHandlers.push({ obj: this, func: dblClick }); var dblClickMain = this.getEventHandlerFromArray(dblClickEventHandlers); if (dblClickMain) { this.map.events.register('dblclick', this.map, dblClickMain); this.hasDblClick = true;}
}, initLoadingControl: function(json) { var loadObjId = 'loading' + json.cid; var loadObj = document.getElementById(loadObjId); var loadJsonObj = json.controls.LoadingImage; if (loadJsonObj.enabled && (loadObj == null || loadObj == 'undefined')) { loadObj = CreateImageNode(loadObjId, loadJsonObj, parseInt(this.map.div.clientWidth), parseInt(this.map.div.clientHeight), json.rootPath + LoadingImageUrl); this.map.div.appendChild(loadObj);}
}, initOverlays: function(json) { var layers = new Array(); if (json.layers.length == 0) { if (CheckObjectExists(json.backgroundOverlay)) { var layer = null; var oType = json.backgroundOverlay.otype.toUpperCase(); if (oType == 'LAYER' && (json.backgroundOverlay.visibility || !json.backgroundOverlay.isDefault)) { layer = this.getLayerOverlay(json.backgroundOverlay, json.cid);} else if (oType != 'LAYER') { layer = this.getLayerByJson(json.backgroundOverlay, json.cid);}
if (layer) { layers.push(layer);}
}
if (CheckObjectExists(json.staticOverlay)) { if (json.staticOverlay.visibility || !json.staticOverlay.isDefault) { var staticOverlay = this.getLayerOverlay(json.staticOverlay, json.cid); layers.push(staticOverlay);}
}
if (CheckObjectExists(json.dynamicOverlay)) { if (json.dynamicOverlay.visibility || !json.dynamicOverlay.isDefault) { var dynamicOverlay = this.getLayerOverlay(json.dynamicOverlay, json.cid); layers.push(dynamicOverlay);}
}
if (CheckObjectExists(json.markerOverlay)) { if (json.markerOverlay.visibility || !json.markerOverlay.isDefault) { var markerOverlay = this.getMarkerOverlay(json.markerOverlay); markerOverlay.gridSize = json.markerOverlay.gridSize; layers.push(markerOverlay); this.markerOverlayIds.push(json.markerOverlay.Id);}
}
} else { for (var i = 0; i < json.layers.length; i++) { var overlayJson = json.layers[i]; var otype = overlayJson.otype.toUpperCase(); var overlay = this.getLayerByJson(overlayJson, json.cid); if (overlay) { layers.push(overlay); if (otype == 'MARKERS') this.markerOverlayIds.push(overlayJson.Id); else if (otype == 'SIMPLEMARKERS') this.simpleMarkerOverlayIds.push(overlayJson.Id);}
}
}
if (layers.length != 0) { var hasBaseLayer = false; for (var i = 0; i < layers.length; i++) { if (layers[i].isBaseLayer) { hasBaseLayer = true; break;}
}
if (!hasBaseLayer) this.addBlankWmsLayer(); this.onOverlaysDrawing(layers); this.map.addLayers(layers);} else { this.addBlankWmsLayer();}
}, getLayerByJson: function(json, clientId) { var otype = json.otype.toUpperCase(); var layer = null; if (otype == 'WMS') { layer = this.getWmsOverlay(json);} else if (otype == 'LAYER') { layer = this.getLayerOverlay(json, clientId);} else if (otype == "MARKERS") { layer = this.getMarkerOverlay(json); layer.gridSize = json.gridSize;} else if (otype == "SIMPLEMARKERS") { layer = this.getSimpleMarkerOverlay(json);} else { layer = this.getSphericalOverlay(json);}
return layer;}, initControls: function(json) { var ctrJson = json.controls; for (var key in ctrJson) { var enabled = ctrJson[key].enabled; var control = null; if (key == 'LoadingImage') { continue;} else if (key == 'Logo' && enabled) { var url = DefaultLogoUrl; if (ctrJson[key].url && ctrJson[key].url != '') { url = ctrJson[key].url;}
control = new OpenLayers.Control.Logo(url); control.id = key;} else if (enabled) { var options = ctrJson[key]; if (json.cursor && key == 'Navigation') { options.defaultCursor = json.cursor; options.defaultCursorUrl = json.cursorUrl;} else if (key == 'LayerSwitcher') { options.activeColor = ctrJson[key].activeColor; if (ctrJson[key].onLayerChanged != '') { eval("options.onLayerChanged = " + ctrJson[key].onLayerChanged);}
}
control = new Control(key, options).element; control.id = key;}
if (control && !this.map.getControl(key)) { this.map.addControl(control); if (key == 'OverviewMap' || key == 'LayerSwitcher') { control.maximizeControl(); if (key == 'LayerSwitcher') { control.baseLbl.innerHTML = OpenLayers.i18n("BaseOverlays");}
} else if (key == 'Navigation') { control.dragPan.defaultCursor = control.defaultCursor; control.dragPan.defaultCursorUrl = control.defaultCursorUrl; if (ctrJson[key].wheelDisabled) { control.disableZoomWheel();}
if (this.hasDblClick) { control.handlers.click.double = false; control.handlers.click.stopDouble = false;}
}
}
}
this.map.addControl(new OpenLayers.Control.NavigationHistory('NavHistory'));}, initExtent: function(json) { if (!this.map.baseLayer || this.map.layers.length == 0) { return;}
if (json.zoom >= 0) { if (json.zoom > this.map.getNumZoomLevels() - 1) { json.zoom = this.map.getNumZoomLevels() - 1;}
this.map.setCenter(new OpenLayers.LonLat(json.centerX, json.centerY), json.zoom);} else { var extent = ConvertJsonToBounds(json.currentExtent); if (IsBoundsValidated(extent)) { var center = extent.getCenterLonLat(); var zoom = this.map.getZoomForExtent(extent); this.map.setCenter(center, zoom);}
}
}, initPopups: function(json) { if (json.popups) { for (var i = 0; i < json.popups.length; i++) { var popupCreator = new Popup(json.popups[i], null); this.map.addPopup(popupCreator.element); var isPopupVisible = json.popups[i].visibility; popupCreator.setVisible(isPopupVisible); if (isPopupVisible && typeof (OnPopupShowing) != 'undefined' && OnPopupShowing != null) { OnPopupShowing.call(popupCreator.element, { isLeft: popupCreator.element.left, isTop: popupCreator.element.top });}
}
}
}, initDrawControls: function() { this.editOverlay = new OpenLayers.Layer.Vector('EditOverlay'); this.editOverlay.displayInLayerSwitcher = false; this.map.addLayer(this.editOverlay); var onClientDrawEnd = null, onClientEditEnd = null, onServerTrackShapeEnd = null; if (this.json.onClientDrawEnd && this.json.onClientDrawEnd != '') { onClientDrawEnd = eval(this.json.onClientDrawEnd);}
if (this.json.onClientEditEnd && this.json.onClientEditEnd != '') { onClientEditEnd = eval(this.json.onClientEditEnd);}
if (this.json.hasTrackShapeEnd && this.json.hasTrackShapeEnd != '') { onServerTrackShapeEnd = function(evt) { __doPostBack(this.map.uniqueId, 'FINISHEDTRACKSHAPE^');};}
var drawEndHandlers = new Array(); var editEndHandlers = new Array(); if (onClientDrawEnd)
drawEndHandlers.push({ obj: this, func: onClientDrawEnd }); if (onClientEditEnd)
editEndHandlers.push({ obj: this, func: onClientEditEnd }); if (onServerTrackShapeEnd) { drawEndHandlers.push({ obj: this, func: onServerTrackShapeEnd }); editEndHandlers.push({ obj: this, func: onServerTrackShapeEnd });}
var onDrawEnd = this.getEventHandlerFromArray(drawEndHandlers); var onEditEnd = this.getEventHandlerFromArray(editEndHandlers); var modifyMode = this.getModifyMode(this.json.editOverlay.editSettings); var optionsEdit = { mode: modifyMode, id: 'Modify' }; var optionsCircle = { handlerOptions: { sides: CircleSide }, id: 'Circle' }; var optionsEllipse = { handlerOptions: { sides: CircleSide, irregular: true }, id: 'Ellipse' }; var optionsRectangle = { handlerOptions: { irregular: true }, id: 'Rectangle' }; this.paintControls = { Point: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.Point, { id: 'Point' }), Line: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.Path, { id: 'Line' }), Polygon: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.Polygon, { id: 'Polygon' }), Square: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.RegularPolygon, { id: 'Square' }), Circle: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.RegularPolygon, optionsCircle), Ellipse: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.RegularPolygon, optionsEllipse), Rectangle: new OpenLayers.Control.DrawFeature(this.editOverlay, OpenLayers.Handler.RegularPolygon, optionsRectangle), Modify: new OpenLayers.Control.ModifyFeature(this.editOverlay, optionsEdit), Normal: null
}; this.addControlsInJson(this.paintControls, onDrawEnd, onEditEnd);}, getModifyMode: function(modifySettings) { var modifyMode = 0; if (modifySettings.resize) modifyMode |= OpenLayers.Control.ModifyFeature.RESIZE
if (modifySettings.drag) modifyMode |= OpenLayers.Control.ModifyFeature.DRAG; if (modifySettings.rotate) modifyMode |= OpenLayers.Control.ModifyFeature.ROTATE; if (modifySettings.reshape) modifyMode |= OpenLayers.Control.ModifyFeature.RESHAPE; return modifyMode;}, initEditOverlay: function(json) { if (json && json != 'undefined' && json.features && json.features.length != 0) { if (this.editOverlay == null) { this.initDrawControls();}
var featuresObj = json.features; var featureArray = new Array(); for (var i = 0; i < featuresObj.length; i++) { var featureObj = featuresObj[i]; var featureID = featureObj.id; var featureWkt = featureObj.wkt; var fieldValues = new Array(); for (var key in featureObj.values) { fieldValues.push({ Key: key, Value: featureObj.values[key] });}
var feature = new OpenLayers.Format.WKT().read(featureWkt); feature.fid = featureID; feature.fieldValues = fieldValues; featureArray.push(feature);}
this.editOverlay.addFeatures(featureArray);}
}, initHighlightOverlay: function(json) { if (json && json.features && json.features.length != 0) { var highlightOverlay = new OpenLayers.Layer.Vector('HighlightOverlay'); highlightOverlay.displayInLayerSwitcher = false; highlightOverlay.id = 'HighlightOverlay'; this.map.addLayer(highlightOverlay); highlightOverlay.events.includeXY = true; highlightOverlay.events.fallThrough = true; json.style.pointRadius = PointRadius; json.highlightStyle.pointRadius = PointRadius; highlightOverlay.style = json.style; var options = { hover: true, selectStyle: json.highlightStyle }; var selectControl = new OpenLayers.Control.SelectFeature(highlightOverlay, options); this.map.addControl(selectControl); selectControl.activate(); selectControl.onSelect = function(feature) { SelectedFeature = feature;}; selectControl.onUnselect = function() { SelectedFeature = null;}; var featureList = new Array(); var toolTip = json.toolTip; for (var i = 0; i < json.features.length; i++) { var wkt = json.features[i].wkt; var feature = new OpenLayers.Format.WKT().read(wkt); feature.id = json.features[i].id; var fieldValues = new Array(); for (var key in json.features[i].values) { fieldValues.push({ Key: key, Value: json.features[i].values[key] });}
feature.fieldValues = fieldValues; if (toolTip && toolTip != '' && toolTip != 'undefined')
feature.toolTip = toolTip; featureList.push(feature);}
highlightOverlay.addFeatures(featureList); highlightOverlay.events.register('click', highlightOverlay, function(e) { HideContextMenus();}); if (json.onClientClick && json.onClientClick != '') { highlightOverlay.events.register('click', highlightOverlay, eval(json.onClientClick));}
if (json.click) { highlightOverlay.events.register('click', highlightOverlay, function(evt) { var lonlat = this.getLonLatFromViewPortPx(evt.xy); var featureExtent = this.getDataExtent(); if (featureExtent.containsLonLat(lonlat)) { if (SelectedFeature)
__doPostBack(this.map.uniqueId, 'HIGHLIGHTOVERLAYCLICK^' + lonlat.lon + '^' + lonlat.lat + '^' + SelectedFeature.id);}
});}
if (CheckObjectExists(json.contextMenu)) { highlightOverlay.ctxJson = json.contextMenu; if (highlightOverlay.div.oncontextmenu != 'undefined')
highlightOverlay.div.oncontextmenu = function() { return false;}; highlightOverlay.events.register('mousedown', highlightOverlay, function(evt) { HideContextMenus(); if (evt && evt.button == 2) { var lonlat = this.map.getLonLatFromPixel(evt.xy); var featureExtent = this.getDataExtent(); if (featureExtent.containsLonLat(lonlat)) { var target = this.CLASS_NAME + '|' + this.id; var contextMenu = new ContextMenu(this.ctxJson, lonlat, target, this.map.uniqueId); for (var i = 0; i < this.ctxJson.items.length; i++) { contextMenu.addItem(this.ctxJson.items[i]);}
contextMenu.moveTo(evt.clientX, evt.clientY); contextMenu.display(true); document.getElementById(this.map.clientId).appendChild(contextMenu.div); CurrentContextMenu = (contextMenu == undefined ? null : contextMenu);}
}
});}
}
}, initBaseOverlay: function(baseOverlayId) { if (baseOverlayId && baseOverlayId != 'undefined') { var layer = this.map.getLayer(baseOverlayId); if (!layer) { layer = this.map.getLayer('_blankWms');}
if (layer) { this.map.setBaseLayer(layer); if (!layer.initVisibility && layer.initVisibility != 'undefined' && layer.initVisibility != undefined) { layer.setVisibility(false);}
}
}
}, initMapMode: function() { var trackMode = this.json.editOverlay.mode; if (this.editOverlay == null) { if (trackMode == 'None') return; else this.initDrawControls();}
for (var key in this.paintControls) { if (this.paintControls[key]) { if (key == trackMode) this.paintControls[key].activate(); else this.paintControls[key].deactivate();}
}
}, addBlankWmsLayer: function() { var blankWms = new OpenLayers.Layer.WMS('_blankWms', '', {}, { 'displayInLayerSwitcher': false, 'initVisibility': false, 'visibility': false }); blankWms.id = '_blankWms'; this.map.addLayer(blankWms);}, releasePageLoad: function() { Sys.Application.remove_load(CreateAllMaps);}, extentChanged: function(e) { if (!this.map.panByPopup) this.sendMarkersRequest(); if (typeof (OnExtentChanged) != 'undefined') OnExtentChanged(this.map);}, extentChangedPostBack: function(e) { if (!this.load)
if (this.map.extentChanged && this.map.extentChanged != null)
__doPostBack(this.map.uniqueId, 'EXTENTCHANGED'); this.load = false;}, sendMarkersRequest: function() { for (var i = 0; i < this.markerOverlayIds.length; i++) { var markerOverlayId = this.markerOverlayIds[i]; var overlay = this.map.getLayer(markerOverlayId); var url = this.getMarkerRequestUrl(markerOverlayId, overlay.gridSize); if (url) { CurrentMapClientId = this.map.clientId; var httpRequest = new OpenLayers.Ajax.Request(url, { 'method': 'get', 'onComplete': function(transport) { if (transport.status == 200) { var map = eval('parser' + CurrentMapClientId + '.map'); AddMarkersByAjax(map, transport.responseText);}
}
});}
}
}, addControlsInJson: function(controls, onDrawEnd, onEditEnd) { for (var key in controls) { if (controls[key]) { if (key == 'Modify') { if (onEditEnd) { controls[key].onModificationEnd = onEditEnd;}
} else if (key != 'Normal') { if (onDrawEnd) { controls[key].featureAdded = onDrawEnd;}
}
this.map.addControl(controls[key]);}
}
}, addSimpleMarkers: function() { for (var i = 0; i < this.simpleMarkerOverlayIds.length; i++) { var layer = this.map.getLayer(this.simpleMarkerOverlayIds[i]); var hasCtx = false; var rootPath = layer.rootPath; if (layer.isSimpleMarkerOverlay && layer.isSimpleMarkerOverlay != undefined) { if (layer.markersJson && layer.markersJson.length != 0) { for (var j = 0; j < layer.markersJson.length; j++) { var markerJson = layer.markersJson[j]; if (!markerJson.visible) { continue;}
var markerCreator = new Marker(markerJson, rootPath); markerCreator.overlayId = layer.id; markerCreator.mapUid = this.map.uniqueId; markerCreator.mapCid = this.map.clientId; markerCreator.currentZoom = this.map.getZoom(); if (markerJson.contextMenu && markerJson.contextMenu != 'undefined' && markerJson.contextMenu.items.length != 0) { markerCreator.setContextMenu(markerJson); hasCtx = true;}
var marker = markerCreator.element; if (markerJson.popup && markerJson.popup != 'undefined' && markerJson.popup.html && markerJson.popup.html != '') { marker.popupJson = markerJson.popup; marker.popupDelay = markerJson.popupdelay; marker.initializePopup(this.map); marker.events.register('mouseover', marker, function(evt) { this.showPopup();}); marker.events.register('mouseout', marker, function(evt) { this.hidePopup();});}
layer.wireDragEvents(); marker = GetHookedClickEventMarker(marker, layer); layer.addMarker(marker); if (hasCtx) { layer.div.oncontextmenu = function() { return false;};} else { layer.div.oncontextmenu = null;}
}
layer.markersJson = null;}
}
}
}, setCursor: function() { if (this.json.cursor == 'Custom') { this.map.div.style.cursor = 'url(' + this.json.cursorUrl + ')';} else { this.map.div.style.cursor = this.json.cursor;}
}, getSphericalOverlay: function(json) { var creator = new SphericalOverlay(json); creator.createOverlay(); return creator.element;}, getWmsOverlay: function(json) { var creator = new WmsOverlay(json, this.pageName); creator.setResolutions(this.map.resolutions); creator.createWms(); creator.setProjection(json.SRS); creator.hookLoadingImage(this.map.clientId); return creator.element;}, getLayerOverlay: function(json, mapClientId) { var creator = new LayerOverlay(json, this.pageName); creator.setResolutions(this.map.resolutions); creator.createWms(); creator.hookLoadingImage(this.map.clientId); creator.element.mergeNewParams({ 'clientid': mapClientId, 'extra': json.extra }); creator.element.projection = new OpenLayers.Projection(json.projection); return creator.element;}, getMarkerOverlay: function(json) { var creator = new MarkerOverlay(json); creator.createMarkerOverlay(); creator.hookEvent(json.click); creator.element.rootPath = this.json.rootPath; return creator.element;}, getSimpleMarkerOverlay: function(json) { var creator = new SimpleMarkerOverlay(json); creator.setOptions(json); creator.createMarkerOverlay(); creator.hookEvent(json.click); creator.hookMarkersJson(json.markers); creator.element.rootPath = this.json.rootPath; return creator.element;}, getMarkerRequestUrl: function(markerOverlayId, gridSize) { var url = null; if (this.markerOverlayIds.length != 0) { url = 'markers_GeoResource.axd?'; url += 'overlayIds=' + markerOverlayId; url += '&extent=' + ConvertBoundsToString(this.map.getExtent()); url += '&level=' + (parseInt(this.map.getZoom()) + 1); url += '&pageName=' + this.pageName; url += '&clientId=' + this.json.cid; url += '&scale=' + this.map.getScale(); url += '&gridSize=' + gridSize; url += '&extra=' + Math.random().toString();}
return url;}, getResolutionList: function(scales, units) { var resolutions = new Array(); for (var i = 0; i < scales.length; i++) { var resolution = OpenLayers.Util.getResolutionFromScale(scales[i], units); resolutions.push(resolution);}
return resolutions;}, getEventHandlerFromArray: function(handlers) { var eventHandler = null; if (handlers.length != 0) { eventHandler = function(evt) { var result = null; for (var i = 0; i < handlers.length; i++) { var sender = handlers[i].obj; var func = handlers[i].func; result = func.apply(sender, [evt]); if (!result && result != undefined) break;}
};}
return eventHandler;}, registerChangeBaseLayerEvent: function(json) { if (!this.map.baseLayer) { return;}
var lastBaseLayer = document.getElementById('__BASELAYERCHANGEDSTATUSSTORAGE' + this.map.clientId); if (json.onClientBaseOverlayChanged && json.onClientBaseOverlayChanged != '')
this.map.events.register('changebaselayer', this.map, eval(json.onClientBaseOverlayChanged)); if (json.baseOverlayChanged) { this.map.events.register('changebaselayer', this.map, function(e) { __doPostBack(json.uid, 'BASELAYERCHANGED' + '^' + this.baseLayer.name + '^' + lastBaseLayer.value);});}; lastBaseLayer.value = this.map.baseLayer.name;}, registerWindowSizeChangedEvent: function(map) { var registerEvents = function(element, eventName, eventHandler) { if (element.addEventListener) { element.addEventListener(eventName, eventHandler, false);} else if (element.attachEvent) { element.attachEvent('on' + eventName, eventHandler);} else { eval("element.on" + eventName + "=eventHandler");}
}; var resizeVEMap = function(veLayer, newWidth, newHeight) { veLayer.mapelement.style.width = newWidth; veLayer.mapelement.style.height = newHeight; veLayer.Resize();}
var onMapResize = function(map) { for (var i = 0; i < map.layers.length; i++) { if (map.layers[i].CLASS_NAME == 'OpenLayers.Layer.VirtualEarth')
resizeVEMap(map.layers[i].mapObject, map.div.clientWidth, map.div.clientHeight);}
}; registerEvents(window, 'resize', function() { onMapResize(map);});}, onOverlaysDrawing: function(layers) { if (typeof (OnOverlaysDrawing) != 'undefined') { OnOverlaysDrawing(layers);}
}, onMapCreating: function(map) { if (typeof (OnMapCreating) != 'undefined') { OnMapCreating(map);}
}, onMapCreated: function(map) { if (typeof (OnMapCreated) != 'undefined') { OnMapCreated(map);}
}, createMap: function() { this.onMapCreating(this.map); this.initOverlays(this.json); this.initBaseOverlay(this.json.baselayerid); this.initExtent(this.json); this.addSimpleMarkers(); this.initPopups(this.json); this.initControls(this.json); this.initHighlightOverlay(this.json.highlightOverlay); this.initEditOverlay(this.json.editOverlay); this.initMapMode(); this.registerChangeBaseLayerEvent(this.json); this.releasePageLoad(); this.onMapCreated(this.map); this.map.panByPopup=false; }
});
var ThinkGeo = Class.Create(); Class.Extent(ThinkGeo.prototype, { clientId: null, initialize: function(clientId) { this.clientId = clientId;}, GetMapParser: function() { eval('var parser = parser' + this.clientId); return parser;}, GetCurrentExtent: function() { return this.GetMapParser().map.getExtent();}, GetZoomLevel: function() { return this.GetOpenLayersMap().getZoom() + 1;}, SetCenter: function(lon, lat) { var mapcontrol = this.GetMapParser().map; mapcontrol.setCenter(new OpenLayers.LonLat(lon, lat), mapcontrol.getZoom(), false, false);}, ZoomIn: function() { this.GetMapParser().map.zoomIn();}, ZoomOut: function() { this.GetMapParser().map.zoomOut();}, ZoomToExtent: function(extent) { this.GetMapParser().map.zoomToExtent(extent);}, PanByScreenPixel: function(x, y) { this.GetMapParser().map.pan(x, y);}, PanToWorldCoordinate: function(x, y) { var xy = new OpenLayers.LonLat(x, y); this.GetMapParser().map.panTo(xy);}, ZoomToPreviousExtent: function() { var nav = this.GetMapParser().map.getControlsByClass('OpenLayers.Control.NavigationHistory'); nav[0].previousTrigger();}, ZoomToNextExtent: function() { var nav = this.GetMapParser().map.getControlsByClass('OpenLayers.Control.NavigationHistory'); nav[0].nextTrigger();}, ToggleExtent: function() { var nav = this.GetMapParser().map.getControlsByClass('OpenLayers.Control.NavigationHistory'); var current = nav[0].previousStack.shift(); var state = nav[0].previousStack.shift(); if (state != undefined) { nav[0].previousStack.unshift(state); nav[0].previousStack.unshift(current); nav[0].nextStack.unshift(current); nav[0].previousStack.unshift(state); nav[0].restoring = true; nav[0].restore(state); nav[0].restoring = false; nav[0].onNextChange(nav[0].nextStack[0], nav[0].nextStack.length); nav[0].onPreviousChange( nav[0].previousStack[1], nav[0].previousStack.length + 1 );} else { nav[0].previousStack.unshift(current);}
return state;}, SetDrawMode: function(drawMode) { eval('var parser = parser' + this.clientId); if (!parser.editOverlay) { parser.initDrawControls();}
var map = parser.map; if (drawMode == 'Normal') { for (var key in parser.paintControls) { if (key != 'Normal') { parser.paintControls[key].deactivate();}
}
} else { for (var key in parser.paintControls) { if (key == drawMode && drawMode != 'Normal') { var control = map.getControl(key); control.activate();}
else if (key != 'Normal') { var control = map.getControl(key); control.deactivate();}
}
}
}, SetEditSetting: function(editMode) { this.SetDrawMode('Modify'); eval('var parser = parser' + this.clientId); parser.paintControls['Modify'].deactivate(); parser.paintControls['Modify'].mode = editMode; parser.paintControls['Modify'].activate();}, ClearFeatures: function() { eval('var parser = parser' + this.clientId); if (parser.editOverlay.features.length != 0) { parser.editOverlay.removeFeatures(parser.editOverlay.features);}
}, CancelLatestFeature: function() { eval('var parser = parser' + this.clientId); if (!parser.editOverlay) { alert('no features left here.'); return;}
if (parser.editOverlay.features.length > 0) { if (parser.paintControls['Modify'].active) { var modifyEnd = parser.paintControls['Modify'].onModificationEnd; parser.paintControls['Modify'].onModificationEnd = function() { }; parser.paintControls['Modify'].deactivate(); parser.paintControls['Modify'].onModificationEnd = modifyEnd;}
parser.editOverlay.removeFeatures([parser.editOverlay.features[parser.editOverlay.features.length - 1]]);}
else { alert('no features left here.');}
}, PrintMap: function() { var controlIds = ''; for (var controlIndex = 0; controlIndex < this.GetOpenLayersMap().controls.length; controlIndex++) { controlIds += this.GetOpenLayersMap().controls[controlIndex].id + ',';}
if (controlIds.length != 0) { controlIds = controlIds.substr(0, controlIds.length - 1);}
window.open('print_GeoResource.axd?containerid=' + this.GetOpenLayersMap().div.id + '&controls=' + controlIds, 'PrintPreview');}, GetCenter: function() { return this.GetOpenLayersMap().getCenter();}, GetOpenLayersMap: function() { return this.GetMapParser().map;}, GetCurrentBaseLayer: function() { return this.GetOpenLayersMap().baseLayer;}, SetBaseLayer: function(layerId) { var oplMap = this.GetOpenLayersMap(); oplMap.setBaseLayer(oplMap.getLayer(layerId));}, SetCurrentBackgroundMapType: function(backgroundMapType) { if (!backgroundMapType) { alert("Background Map Type Error.");} else { try { var baseLayer = this.GetCurrentBaseLayer(); baseLayer.type = backgroundMapType; if (baseLayer.CLASS_NAME == "OpenLayers.Layer.Google") { baseLayer.setMapType();} else if (baseLayer.CLASS_NAME == "OpenLayers.Layer.VirtualEarth") { baseLayer.mapObject.SetMapStyle(backgroundMapType)
} else if (baseLayer.CLASS_NAME == "OpenLayers.Layer.Yahoo") { baseLayer.mapObject.setMapType(backgroundMapType)
}
} catch (e) { }
}
}, Destory : function(){ var mapParser = this.GetMapParser(); mapParser.destroy();}
}); var EditSettings = { Reshape: 1, Resize: 2, Rotate: 4, Drag: 8 }; theForm.onsubmit = function() { for (var i = 0; i < MultiMap.length; i++) { var cid = MultiMap[i]; eval('var parser = parser' + cid); SynchronizeMapInfo(parser); SynchronizeVectors(parser.editOverlay, parser.map.clientId, parser.paintControls); SynchronizeSimpleMarkers(parser);}
return true;}
function SynchronizeMapInfo(parser) { var zoom = parser.map.getZoom(); var result = ConvertBoundsToString(parser.map.getExtent()); result += ',' + parser.map.getScale(); result += ',' + ConvertLonLatToString(parser.map.getCenter()); result += ',' + parser.map.getZoom(); result += ',' + parser.map.div.offsetWidth; result += ',' + parser.map.div.offsetHeight; result += ',' + parser.map.baseLayer.id; result += ','; for (var i = 0; i < parser.map.layers.length; i++) { var layer = parser.map.layers[i]; if (!layer.isBaseLayer) { var visible = layer.getVisibility(); result += layer.id + '^' + (visible ? '1' : '0') + '%';}
}
result += ','; for (var i = 0; i < parser.map.popups.length; i++) { var popup = parser.map.popups[i]; if (!popup.isMarkerHoverPopup || popup.isMarkerHoverPopup == 'undefined') { result += popup.id; if (popup.visible()) { result += '^1%';} else { result += '^0%';}
}
}
document.getElementById("__RestoreStatusField" + parser.map.clientId).value = result;}
function SynchronizeVectors(editOverlay, clientId, paintControls) { if (editOverlay) { if (editOverlay.features.length > 0) { paintControls['Modify'].deactivate(); var jsonObject = { features: null }; var submitArray = new Array(); for (var i = 0; i < editOverlay.features.length; i++) { var featureId = editOverlay.features[i].fid; var featureWkt = editOverlay.features[i].geometry.toString(); var fieldValues = new Array(); if (editOverlay.features[i].fieldValues) { for (var j = 0; j < editOverlay.features[i].fieldValues.length; j++) { var fieldValue = editOverlay.features[i].fieldValues[j]; fieldValues.push({ 'Key': fieldValue.Key, 'Value': fieldValue.Value });}
}
submitArray.push({ id: featureId, wkt: featureWkt, fieldValues: fieldValues });}
jsonObject.features = submitArray; var serializer = Sys.Serialization.JavaScriptSerializer; var jsonString = serializer.serialize(jsonObject); document.getElementById('__RestoreVectors' + clientId).value = jsonString;}
}
}
function SynchronizeSimpleMarkers(parser) { var tempMap = parser.map; var simpleMarkerOverlayIds = parser.simpleMarkerOverlayIds; var overlaysJson = new Array(); for (var i = 0; i < simpleMarkerOverlayIds.length; i++) { var overlayJson = {}; overlayJson.id = simpleMarkerOverlayIds[i]; overlayJson.markers = new Array(); var layer = tempMap.getLayer(overlayJson.id); for (var j = 0; j < layer.markers.length; j++) { if (layer.markers[j].isShadow && layer.markers[j].isShadow != undefined)
continue; var markerJson = {}; markerJson.id = layer.markers[j].id; markerJson.x = layer.markers[j].lonlat.lon; markerJson.y = layer.markers[j].lonlat.lat; overlayJson.markers.push(markerJson);}
overlaysJson.push(overlayJson);}
var serializer = Sys.Serialization.JavaScriptSerializer; var jsonString = serializer.serialize(overlaysJson); document.getElementById('__SimpleMarkerOverlayField' + parser.map.clientId).value = jsonString;}
var ContextMenu = Class.Create(); var ContextMenuItem = Class.Create(); Class.Extent(ContextMenu.prototype, { id: null, div: null, items: null, lonlat: null, target: null, mapUniqueId: null, initialize: function(json, lonlat, target, mapUniqueId) { this.id = json.id; this.lonlat = lonlat; this.target = target; this.mapUniqueId = mapUniqueId; this.div = NewDomNode('DIV'); this.div.id = this.id; if (CheckCssName(json.css)) { this.div.className = json.css;} else { this.setDefaultStyle();}
this.div.style.position = 'absolute'; this.div.style.width = json.w == 0 ? '100px' : (json.w + 'px'); this.div.style.zIndex = 100000; this.div.style.display = 'none'; this.div.oncontextmenu = function() { return false;};}, addItem: function(itemJson) { var item = new ContextMenuItem(itemJson); item.parent = this; item.div.parentId = this.id; item.div.lonlat = this.lonlat; item.div.target = this.target; item.div.uid = this.mapUniqueId; this.div.appendChild(item.div);}, display: function(visible) { if (visible) { this.div.style.display = 'block';} else { if (this.div.parentNode) { this.div.parentNode.removeChild(this.div); CurrentContextMenu = this;} else { CurrentContextMenu = null;}
}
}, setDefaultStyle: function() { this.div.style.padding = '1px'; this.div.style.backgroundColor = 'white'; this.div.style.border = '#cccccc 1px solid'; this.div.style.borderRight = '#333333 1px solid'; this.div.style.borderBottom = '#333333 1px solid'; this.div.style.lineHeight = '18px';}, moveTo: function(x, y) { this.div.style.left = x + 'px'; this.div.style.top = y + 'px';}
}); Class.Extent(ContextMenuItem.prototype, { id: null, div: null, parent: null, initialize: function(json) { this.id = json.id; this.div = NewDomNode('DIV'); this.div.id = this.id; this.div.innerHTML = json.html; if (CheckCssName(json.css)) { this.div.className = json.css;} else { this.setDefaultStyle();}
this.div.normalCss = json.css; this.div.hoverCss = json.hoverCss; this.div.onmouseover = function() { if (CheckCssName(this.hoverCss)) { this.className = this.hoverCss;} else { this.style.backgroundColor = '#99ffff';}
}; this.div.onmouseout = function() { if (CheckCssName(this.normalCss)) { this.className = this.normalCss;} else { this.style.backgroundColor = 'white';}
}; if (json.click && json.click != 'undefined') { this.div.onclick = function(evt) { __doPostBack(this.uid, 'CONTEXTMENUCLICK^' + this.lonlat.lon + '^' + this.lonlat.lat + '^' + this.target + '^' + this.id + '^' + this.parentId);}
} else if (json.clientClick && json.clientClick != 'undefined') { eval('var click = ' + json.clientClick); this.div.onclick = click;}
}, setDefaultStyle: function() { this.div.style.paddingLeft = '4px'; this.div.style.paddingTop = '4px'; this.div.style.fontSize = '10px'; this.div.style.fontFamily = 'verdana'; this.div.style.color = '#0000cc'; this.div.style.cursor = 'pointer'; this.div.style.backgroundColor = 'white';}
}); function CheckCssName(css){ if(css && css!='undefined' && css!=''){ return true;}else return false;}