Merge 2.0 branch to trunk.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1369 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -420,8 +420,8 @@ OpenLayers.Bounds.prototype = {
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
add:function(x, y){
|
||||
return new OpenLayers.Box(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -119,16 +119,18 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
inputElem.type = (baseLayer) ? "radio" : "checkbox";
|
||||
inputElem.value = layer.name;
|
||||
inputElem.checked = checked;
|
||||
inputElem.defaultChecked = checked;
|
||||
inputElem.layer = layer;
|
||||
inputElem.control = this;
|
||||
Event.observe(inputElem, "mouseup",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
|
||||
// create span
|
||||
var labelSpan = document.createElement("span");
|
||||
labelSpan.innerHTML = layer.name;
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "auto";
|
||||
Event.observe(labelSpan,
|
||||
"click",
|
||||
this.onLabelClick.bindAsEventListener(inputElem));
|
||||
|
||||
Event.observe(labelSpan, "click",
|
||||
this.onInputClick.bindAsEventListener(inputElem));
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
@@ -158,11 +160,17 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
*
|
||||
* @param {Event} e
|
||||
*/
|
||||
onLabelClick: function(e) {
|
||||
var clickedRadioButton = ((this.type == "radio") && (this.checked));
|
||||
if (!clickedRadioButton) {
|
||||
|
||||
onInputClick: function(e) {
|
||||
if (this.type == "radio") {
|
||||
this.checked = true;
|
||||
this.layer.map.setBaseLayer(this.layer, true);
|
||||
this.layer.map.events.triggerEvent("changebaselayer");
|
||||
} else {
|
||||
this.checked = !this.checked;
|
||||
this.control.updateMap();
|
||||
}
|
||||
Event.stop(e);
|
||||
},
|
||||
|
||||
/** Need to update the map accordingly whenever user clicks in either of
|
||||
@@ -189,7 +197,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
for(var i=0; i < this.baseLayerInputs.length; i++) {
|
||||
var input = this.baseLayerInputs[i];
|
||||
if (input.checked) {
|
||||
this.map.setBaseLayer(input.layer, true);
|
||||
this.map.setBaseLayer(input.layer, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,6 +279,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
Event.observe(this.div, "mouseup",
|
||||
this.mouseUp.bindAsEventListener(this));
|
||||
Event.observe(this.div, "click",
|
||||
this.ignoreEvent);
|
||||
Event.observe(this.div, "mousedown",
|
||||
this.mouseDown.bindAsEventListener(this));
|
||||
Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
@@ -301,8 +311,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||
Event.observe(this.baseLayersDiv, "click",
|
||||
/*Event.observe(this.baseLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
|
||||
|
||||
@@ -315,8 +326,9 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
this.dataLayersDiv = document.createElement("div");
|
||||
this.dataLayersDiv.style.paddingLeft = "10px";
|
||||
Event.observe(this.dataLayersDiv, "click",
|
||||
/*Event.observe(this.dataLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
*/
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
@@ -60,6 +60,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -80,6 +81,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
}
|
||||
@@ -95,8 +97,8 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
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";
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
@@ -124,20 +126,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomBox) {
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( 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.zoomBoxEnd(evt);
|
||||
} else {
|
||||
if (this.performedDrag) {
|
||||
this.map.setCenter(this.map.center);
|
||||
@@ -173,6 +162,37 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
this.map.zoomOut();
|
||||
},
|
||||
|
||||
/** Zoombox function.
|
||||
*
|
||||
*/
|
||||
zoomBoxEnd: function(evt) {
|
||||
if (this.mouseDragStart != null) {
|
||||
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
|
||||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( 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);
|
||||
} else {
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(end.lon),
|
||||
(end.lat)
|
||||
), this.map.getZoom() + 1);
|
||||
}
|
||||
this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
|
||||
this.zoomBox = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
|
||||
@@ -189,7 +209,7 @@ OpenLayers.Control.MouseDefaults.prototype =
|
||||
var inMap = false;
|
||||
var elem = Event.element(e);
|
||||
while(elem != null) {
|
||||
if (elem == this.map.div) {
|
||||
if (this.map && elem == this.map.div) {
|
||||
inMap = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/MouseDefaults.js
|
||||
*/
|
||||
OpenLayers.Control.MouseToolbar = Class.create();
|
||||
OpenLayers.Control.MouseToolbar.X = 6;
|
||||
OpenLayers.Control.MouseToolbar.Y = 300;
|
||||
OpenLayers.Control.MouseToolbar.prototype =
|
||||
Object.extend( new OpenLayers.Control(), {
|
||||
Object.extend( new OpenLayers.Control(),
|
||||
Object.extend( new OpenLayers.Control.MouseDefaults(), {
|
||||
|
||||
mode: null,
|
||||
|
||||
@@ -35,6 +37,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
this.buttons = new Object();
|
||||
this.map.events.register( "click", this, this.defaultClick );
|
||||
this.map.events.register( "dblclick", this, this.defaultDblClick );
|
||||
this.map.events.register( "mousedown", this, this.defaultMouseDown );
|
||||
this.map.events.register( "mouseup", this, this.defaultMouseUp );
|
||||
@@ -46,9 +49,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
|
||||
this.switchModeTo("pan");
|
||||
this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
|
||||
return this.div;
|
||||
|
||||
},
|
||||
@@ -69,6 +70,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
btn.events = new OpenLayers.Events(this, btn);
|
||||
btn.events.register("mousedown", this, this.buttonClick);
|
||||
btn.events.register("mouseup", this, Event.stop);
|
||||
btn.events.register("click", this, Event.stop);
|
||||
btn.action = id;
|
||||
btn.title = title;
|
||||
btn.alt = title;
|
||||
@@ -93,6 +95,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.performedDrag = false;
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 2);
|
||||
Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -102,8 +106,10 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
this.startViaKeyboard = false;
|
||||
if (evt.shiftKey && this.mode !="zoombox") {
|
||||
this.switchModeTo("zoombox");
|
||||
this.startViaKeyboard = true;
|
||||
} else if (evt.altKey && this.mode !="measure") {
|
||||
this.switchModeTo("measure");
|
||||
} else if (!this.mode) {
|
||||
@@ -122,8 +128,10 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
this.performedDrag = true;
|
||||
break;
|
||||
case "measure":
|
||||
var distance = "";
|
||||
@@ -144,6 +152,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
"absolute");
|
||||
this.measureBox.style.width="4px";
|
||||
this.measureBox.style.height="4px";
|
||||
this.measureBox.style.fontSize = "1px";
|
||||
this.measureBox.style.backgroundColor="red";
|
||||
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.layerContainerDiv.appendChild(this.measureBox);
|
||||
@@ -175,7 +184,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
|
||||
switchModeTo: function(mode) {
|
||||
if (mode != this.mode) {
|
||||
if (this.mode) {
|
||||
if (this.mode && this.buttons[this.mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
|
||||
}
|
||||
if (this.mode == "measure" && mode != "measure") {
|
||||
@@ -188,7 +197,9 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
this.measureStart = null;
|
||||
}
|
||||
this.mode = mode;
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
|
||||
if (this.buttons[mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -205,8 +216,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
case "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";
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
@@ -235,21 +246,8 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( 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.leaveMode();
|
||||
this.zoomBoxEnd(evt);
|
||||
if (this.startViaKeyboard) this.leaveMode();
|
||||
break;
|
||||
case "pan":
|
||||
if (this.performedDrag) {
|
||||
@@ -266,6 +264,12 @@ OpenLayers.Control.MouseToolbar.prototype =
|
||||
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||
this.defaultMouseUp(evt);
|
||||
}
|
||||
},
|
||||
defaultClick: function (evt) {
|
||||
if (this.performedDrag) {
|
||||
this.performedDrag = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
@@ -25,19 +25,33 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
|
||||
this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X,
|
||||
OpenLayers.Control.PanZoomBar.Y);
|
||||
|
||||
// put code here to catch "changebaselayer" event from map, because
|
||||
// we are going to have to redraw this thing each time, because
|
||||
// maxZoom will/might change.
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
|
||||
this.map.events.register("changebaselayer", this, this.redraw);
|
||||
},
|
||||
|
||||
/** clear the div and start over.
|
||||
*
|
||||
*/
|
||||
redraw: function() {
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = "";
|
||||
}
|
||||
this.draw();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
draw: function(px) {
|
||||
// initialize our internal div
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
px = this.position;
|
||||
px = this.position.clone();
|
||||
|
||||
// place the controls
|
||||
this.buttons = new Array();
|
||||
@@ -63,9 +77,9 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
|
||||
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
|
||||
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
|
||||
var slider = OpenLayers.Util.createAlphaImageDiv(id,
|
||||
centered.add(-1,
|
||||
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
|
||||
centered.add(-1, zoomsToEnd * this.zoomStopHeight),
|
||||
new OpenLayers.Size(20,9),
|
||||
imgLocation+"slider.png",
|
||||
"absolute");
|
||||
@@ -79,7 +93,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.sliderEvents.register("click", this, this.doubleClick);
|
||||
|
||||
sz = new OpenLayers.Size();
|
||||
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1);
|
||||
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
|
||||
sz.w = this.zoomStopWidth;
|
||||
var div = null
|
||||
|
||||
@@ -115,7 +129,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.map.events.register("zoomend", this, this.moveZoomBar);
|
||||
|
||||
centered = centered.add(0,
|
||||
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1));
|
||||
this.zoomStopHeight * this.map.getNumZoomLevels());
|
||||
return centered;
|
||||
},
|
||||
/*
|
||||
@@ -136,7 +150,7 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
var y = evt.xy.y;
|
||||
var top = Position.page(evt.object)[1];
|
||||
var levels = Math.floor((y - top)/this.zoomStopHeight);
|
||||
this.map.zoomTo(this.map.getMaxZoomLevel() - levels);
|
||||
this.map.zoomTo((this.map.getNumZoomLevels() -1) - levels);
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
@@ -170,8 +184,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
this.slider.style.top = newTop+"px";
|
||||
}
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
Event.stop(evt);
|
||||
}
|
||||
Event.stop(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -183,8 +197,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
if (!Event.isLeftClick(evt)) return;
|
||||
if (this.zoomStart) {
|
||||
this.div.style.cursor="default";
|
||||
this.map.events.remove("mousemove");
|
||||
this.map.events.remove("mouseup");
|
||||
this.map.events.unregister("mouseup", this, this.passEventToSlider);
|
||||
this.map.events.unregister("mousemove", this, this.passEventToSlider);
|
||||
var deltaY = this.zoomStart.y - evt.xy.y
|
||||
this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
|
||||
this.moveZoomBar();
|
||||
@@ -198,8 +212,8 @@ OpenLayers.Control.PanZoomBar.prototype =
|
||||
*/
|
||||
moveZoomBar:function() {
|
||||
var newTop =
|
||||
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight
|
||||
+ this.startTop + 1;
|
||||
((this.map.getNumZoomLevels()-1) - this.map.getZoom()) *
|
||||
this.zoomStopHeight + this.startTop + 1;
|
||||
this.slider.style.top = newTop + "px";
|
||||
},
|
||||
|
||||
|
||||
@@ -48,9 +48,8 @@ OpenLayers.Feature.WFS.prototype =
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
var point = xmlNode.getElementsByTagName("Point");
|
||||
var text = OpenLayers.Util.getXmlNodeValue(point[0]);
|
||||
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
|
||||
var floats = text.split(",");
|
||||
|
||||
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
|
||||
parseFloat(floats[1])),
|
||||
id: null};
|
||||
|
||||
+33
-22
@@ -51,10 +51,7 @@ OpenLayers.Layer.prototype = {
|
||||
maxResolution: null,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: null,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: null,
|
||||
numZoomLevels: null,
|
||||
|
||||
/** @type float */
|
||||
minScale: null,
|
||||
@@ -148,6 +145,12 @@ OpenLayers.Layer.prototype = {
|
||||
Object.extend(this, this.options);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
onMapResize: function() {
|
||||
//this function can be implemented by subclasses
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bound
|
||||
@@ -163,19 +166,25 @@ OpenLayers.Layer.prototype = {
|
||||
* so that subclasses can override this and take special action once
|
||||
* they have their map variable set.
|
||||
*
|
||||
* Here we take care to bring over any of the necessary default properties
|
||||
* from the map.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.map = map;
|
||||
|
||||
var properties = new Array(
|
||||
'projection', 'minExtent', 'maxExtent',
|
||||
'minScale', 'maxScale',
|
||||
'projection', 'units',
|
||||
'scales', 'resolutions',
|
||||
'maxScale', 'minScale',
|
||||
'maxResolution', 'minResolution',
|
||||
'minZoomLevel', 'maxZoomLevel', 'units',
|
||||
'scales', 'resolutions'
|
||||
|
||||
'minExtent', 'maxExtent',
|
||||
'numZoomLevels'
|
||||
);
|
||||
if (this.map.maxZoomLevel && !this.numZoomLevels) {
|
||||
this.numZoomLevels = this.map.maxZoomLevel + 1;
|
||||
}
|
||||
for(var i=0; i < properties.length; i++) {
|
||||
if (this[properties[i]] == null) {
|
||||
this[properties[i]] = this.map[properties[i]];
|
||||
@@ -220,6 +229,16 @@ OpenLayers.Layer.prototype = {
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* @param {Boolean} isBaseLayer
|
||||
*/
|
||||
setIsBaseLayer: function(isBaseLayer) {
|
||||
this.isBaseLayer = isBaseLayer;
|
||||
if (this.map != null) {
|
||||
this.map.events.triggerEvent("changelayer");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @type String
|
||||
*/
|
||||
@@ -242,19 +261,11 @@ OpenLayers.Layer.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The minimum zoom level that can be reached in this layer
|
||||
* @returns The total number of zoom levels this layer can reach
|
||||
* @type int
|
||||
*/
|
||||
getMinZoomLevel: function() {
|
||||
return this.minZoomLevel;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The maximum zoom level that can be reached in this layer
|
||||
* @type int
|
||||
*/
|
||||
getMaxZoomLevel: function() {
|
||||
return this.maxZoomLevel;
|
||||
getNumZoomLevels: function() {
|
||||
return this.numZoomLevels;
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
@@ -272,7 +283,7 @@ OpenLayers.Layer.prototype = {
|
||||
*/
|
||||
getResolution: function() {
|
||||
var viewSize = this.map.getSize();
|
||||
var extent = this.map.getExtent();
|
||||
var extent = this.getExtent();
|
||||
return Math.max( extent.getWidth() / viewSize.w,
|
||||
extent.getHeight() / viewSize.h );
|
||||
},
|
||||
@@ -316,7 +327,7 @@ OpenLayers.Layer.prototype = {
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
var size = this.map.getSize();
|
||||
var center = this.map.getCenter(); //map center lon/lat
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
|
||||
@@ -37,9 +37,6 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
if (arguments.length > 0) {
|
||||
if (this.pane == null) {
|
||||
this.pane = OpenLayers.Util.createDiv();
|
||||
this.pane.style.width = "100%";
|
||||
this.pane.style.height = "100%";
|
||||
this.pane.style.backgroundColor = "transparent";
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -52,9 +49,15 @@ OpenLayers.Layer.EventPane.prototype =
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
|
||||
|
||||
this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;
|
||||
this.pane.style.display = this.div.style.display;
|
||||
this.pane.style.width="100%";
|
||||
this.pane.style.height="100%";
|
||||
if (/MSIE/.test(navigator.userAgent)) {
|
||||
this.pane.style.background = "url("+OpenLayers.Util.getImagesLocation()+"blank.gif)";
|
||||
}
|
||||
|
||||
if (this.isFixed) {
|
||||
this.map.viewPortDiv.appendChild(this.pane);
|
||||
} else {
|
||||
|
||||
@@ -11,11 +11,6 @@ OpenLayers.Layer.GeoRSS = Class.create();
|
||||
OpenLayers.Layer.GeoRSS.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** GeoRSS layer is never a base layer.
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
/** store url of text file
|
||||
* @type str */
|
||||
location:null,
|
||||
|
||||
@@ -2,31 +2,8 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
if (typeof GMap2 != "undefined") {
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
// it seems like "b" is the main div
|
||||
var div = this.b.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @class
|
||||
@@ -49,7 +26,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
// OPTIONS
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: -1,
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
@@ -65,6 +42,8 @@ OpenLayers.Layer.Google.prototype =
|
||||
if (this.maxExtent == null) {
|
||||
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
|
||||
}
|
||||
this.addContainerPxFunction();
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -147,6 +126,13 @@ OpenLayers.Layer.Google.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
onMapResize: function() {
|
||||
this.gmap.checkResize();
|
||||
},
|
||||
|
||||
/** If we can't load the GMap, then display an error message to the
|
||||
* user and tell them where to go for help.
|
||||
*
|
||||
@@ -259,6 +245,12 @@ OpenLayers.Layer.Google.prototype =
|
||||
if ((this.gmap != null) && (this.gmap.getCenter() != null)) {
|
||||
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
|
||||
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var gZoom = Math.min(Math.max(gZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
|
||||
zoom = this.getOLZoomFromGZoom(gZoom);
|
||||
}
|
||||
return zoom;
|
||||
@@ -287,7 +279,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getOLZoomFromGZoom: function(gZoom) {
|
||||
var zoom = null;
|
||||
if (gZoom != null) {
|
||||
zoom = gZoom;
|
||||
zoom = gZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -302,7 +294,7 @@ OpenLayers.Layer.Google.prototype =
|
||||
getGZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -416,8 +408,34 @@ OpenLayers.Layer.Google.prototype =
|
||||
}
|
||||
return gLatLngBounds;
|
||||
},
|
||||
|
||||
|
||||
|
||||
addContainerPxFunction: function() {
|
||||
if (typeof GMap2 != "undefined" && !GMap2.fromLatLngToContainerPixel) {
|
||||
|
||||
/** Hack-on function because GMAPS does not give it to us
|
||||
*
|
||||
* @param {GLatLng} gLatLng
|
||||
*
|
||||
* @returns A GPoint specifying gLatLng translated into "Container" coords
|
||||
* @type GPoint
|
||||
*/
|
||||
GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {
|
||||
|
||||
// first we translate into "DivPixel"
|
||||
var gPoint = this.fromLatLngToDivPixel(gLatLng);
|
||||
|
||||
// locate the sliding "Div" div
|
||||
// it seems like "b" is the main div
|
||||
var div = this.b.firstChild.firstChild;
|
||||
|
||||
// adjust by the offset of "Div" and voila!
|
||||
gPoint.x += div.offsetLeft;
|
||||
gPoint.y += div.offsetTop;
|
||||
|
||||
return gPoint;
|
||||
};
|
||||
}
|
||||
},
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Google"
|
||||
});
|
||||
|
||||
@@ -42,7 +42,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
destroy: function() {
|
||||
this.clearGrid();
|
||||
this.grid = null;
|
||||
this.alpha = null;
|
||||
this.tileSize = null;
|
||||
OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
@@ -88,30 +87,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} tileID
|
||||
*
|
||||
* @returns The OpenLayers.Tile with the corresponding ID from the grid.
|
||||
* if no tile is found, returns null
|
||||
* @type OpenLayers.Tile
|
||||
*/
|
||||
getTile: function(tileID) {
|
||||
var foundTile = null;
|
||||
if (this.grid) {
|
||||
|
||||
for(var iRow = 0; iRow < this.grid.length; iRow++) {
|
||||
var row = this.grid[iRow];
|
||||
for(var iCol = 0; iCol < row.length; iCol++) {
|
||||
var tile = row[iCol];
|
||||
if (tile.id == tileID) {
|
||||
foundTile = tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return foundTile;
|
||||
},
|
||||
|
||||
/** This function is called whenever the map is moved. All the moving
|
||||
* of actual 'tiles' is done by the map, but moveTo's role is to accept
|
||||
* a bounds and make sure the data that that bounds requires is pre-loaded.
|
||||
@@ -150,6 +125,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @returns A Bounds object representing the bounds of all the currently
|
||||
* loaded tiles (including those partially or not at all seen
|
||||
* onscreen)
|
||||
@@ -170,7 +147,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_initTiles:function() {
|
||||
var viewSize = this.map.getSize();
|
||||
@@ -246,8 +223,16 @@ OpenLayers.Layer.Grid.prototype =
|
||||
this.spiralTileLoad();
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Starts at the top right corner of the grid and proceeds in a spiral
|
||||
* towards the center, adding tiles one at a time to the beginning of a
|
||||
* queue.
|
||||
*
|
||||
* Once all the grid's tiles have been added to the queue, we go back
|
||||
* and iterate through the queue (thus reversing the spiral order from
|
||||
* outside-in to inside-out), calling draw() on each tile.
|
||||
*/
|
||||
spiralTileLoad: function() {
|
||||
var tileQueue = new Array();
|
||||
@@ -279,6 +264,8 @@ OpenLayers.Layer.Grid.prototype =
|
||||
break;
|
||||
}
|
||||
|
||||
// if the test grid coordinates are within the bounds of the
|
||||
// grid, get a reference to the tile.
|
||||
var tile = null;
|
||||
if ((testRow < this.grid.length) &&
|
||||
(testCell < this.grid[0].length)) {
|
||||
@@ -286,12 +273,16 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
|
||||
if ((tile != null) && (!tile.queued)) {
|
||||
//add tile to beginning of queue, mark it as queued.
|
||||
tileQueue.unshift(tile);
|
||||
tile.queued = true;
|
||||
|
||||
//restart the directions counter and take on the new coords
|
||||
directionsTried = 0;
|
||||
iRow = testRow;
|
||||
iCell = testCell;
|
||||
} else {
|
||||
//need to try to load a tile in a different direction
|
||||
direction = (direction + 1) % 4;
|
||||
directionsTried++;
|
||||
}
|
||||
@@ -301,6 +292,7 @@ OpenLayers.Layer.Grid.prototype =
|
||||
for(var i=0; i < tileQueue.length; i++) {
|
||||
var tile = tileQueue[i]
|
||||
tile.draw();
|
||||
//mark tile as unqueued for the next time (since tiles are reused)
|
||||
tile.queued = false;
|
||||
}
|
||||
},
|
||||
@@ -320,67 +312,6 @@ OpenLayers.Layer.Grid.prototype =
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/** Calculates based on resolution, center, and mapsize
|
||||
*
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
var center = this.map.getCenter();
|
||||
if (center != null) {
|
||||
|
||||
var res = this.getResolution();
|
||||
var size = this.map.getSize();
|
||||
var w_deg = size.w * res;
|
||||
var h_deg = size.h * res;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/** go through and remove all tiles from the grid, calling
|
||||
* destroy() on each of them to kill circular references
|
||||
*
|
||||
@@ -462,6 +393,65 @@ OpenLayers.Layer.Grid.prototype =
|
||||
}
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
/* */
|
||||
/********************************************************/
|
||||
|
||||
/** Calculates based on resolution, center, and mapsize
|
||||
*
|
||||
* @returns A Bounds object which represents the lon/lat bounds of the
|
||||
* current viewPort.
|
||||
* @type OpenLayers.Bounds
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
var center = this.map.getCenter();
|
||||
if (center != null) {
|
||||
|
||||
var res = this.map.getResolution();
|
||||
var size = this.map.getSize();
|
||||
var w_deg = size.w * res;
|
||||
var h_deg = size.h * res;
|
||||
|
||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
||||
center.lat - h_deg / 2,
|
||||
center.lon + w_deg / 2,
|
||||
center.lat + h_deg / 2);
|
||||
|
||||
}
|
||||
|
||||
return extent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, 0),
|
||||
this.getNumZoomLevels() - 1);
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.Grid"
|
||||
});
|
||||
|
||||
@@ -36,10 +36,17 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
this.params = Object.extend( new Object(), params);
|
||||
},
|
||||
|
||||
/** When the layer is added to the map, once it has taken all the
|
||||
* relevant properties from the map (in Layer.setMap()), we will
|
||||
* make the call to initialize the layer's resolutions array.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||
this.initResolutions();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -131,31 +138,83 @@ OpenLayers.Layer.HTTPRequest.prototype =
|
||||
return requestString;
|
||||
},
|
||||
|
||||
/** This method's responsibility is to set up the 'resolutions' array
|
||||
* for the layer -- this array is what the layer will use to interface
|
||||
* between the zoom levels of the map and the resolution display of the
|
||||
* layer.
|
||||
*
|
||||
* The user has several options that determine how the array is set up.
|
||||
*
|
||||
* For a detailed explanation, see the following wiki from the
|
||||
* openlayers.org homepage:
|
||||
*
|
||||
* http://trac.openlayers.org/wiki/SettingZoomLevels
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
initResolutions: function() {
|
||||
if (this.scales != null) {
|
||||
this.resolutions = new Array();
|
||||
for(var i = 0; i < this.scales.length; i++)
|
||||
this.resolutions[i] = OpenLayers.Util.getResolutionFromScale(this.scales[i], this.units);
|
||||
this.maxZoomLevel = this.resolutions.length;
|
||||
} else if (this.resolutions != null) {
|
||||
this.maxZoomLevel = this.resolutions.length;
|
||||
|
||||
if ((this.scales != null) || (this.resolutions != null)) {
|
||||
//preset levels
|
||||
if (this.scales != null) {
|
||||
this.resolutions = new Array();
|
||||
for(var i = 0; i < this.scales.length; i++) {
|
||||
this.resolutions[i] =
|
||||
OpenLayers.Util.getResolutionFromScale(this.scales[i],
|
||||
this.units);
|
||||
}
|
||||
}
|
||||
this.numZoomLevels = this.resolutions.length;
|
||||
|
||||
} else {
|
||||
//maxResolution and numZoomLevels
|
||||
|
||||
this.resolutions = new Array();
|
||||
if (this.minScale)
|
||||
this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units);
|
||||
var maxRes = this.getMaxResolution();
|
||||
if (this.maxScale) {
|
||||
/* This will cause this.map.getMaxZoomLevel() to be set the next time
|
||||
* it is called, which means that the next portion here will succeed. */
|
||||
var minRes = OpenLayers.Util.getResolutionFromScale(this.maxScale);
|
||||
this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) / Math.log(2));
|
||||
}
|
||||
for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) {
|
||||
this.resolutions.push(maxRes / Math.pow(2, i));
|
||||
|
||||
// determine maxResolution
|
||||
if (this.minScale) {
|
||||
this.maxResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(this.minScale,
|
||||
this.units);
|
||||
} else if (this.maxResolution == "auto") {
|
||||
var viewSize = this.map.getSize();
|
||||
var wRes = this.maxExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.maxExtent.getHeight()/ viewSize.h;
|
||||
this.maxResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine minResolution
|
||||
if (this.maxScale != null) {
|
||||
this.minResolution =
|
||||
OpenLayers.Util.getResolutionFromScale(this.maxScale);
|
||||
} else if ((this.minResolution == "auto") &&
|
||||
(this.minExtent != null)){
|
||||
var viewSize = this.map.getSize();
|
||||
var wRes = this.minExtent.getWidth() / viewSize.w;
|
||||
var hRes = this.minExtent.getHeight()/ viewSize.h;
|
||||
this.minResolution = Math.max(wRes, hRes);
|
||||
}
|
||||
|
||||
// determine numZoomLevels
|
||||
if (this.minResolution != null) {
|
||||
var ratio = this.maxResolution / this.minResolution;
|
||||
this.numZoomLevels =
|
||||
Math.floor(Math.log(ratio) / Math.log(2)) + 1;
|
||||
}
|
||||
|
||||
// now we have numZoomLevels and maxResolution,
|
||||
// we can populate the resolutions array
|
||||
for (var i=0; i < this.numZoomLevels; i++) {
|
||||
this.resolutions.push(this.maxResolution / Math.pow(2, i));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The currently selected resolution of the map, taken from the
|
||||
* resolutions array, indexed by current zoom level.
|
||||
* @type float
|
||||
*/
|
||||
getResolution: function() {
|
||||
var zoom = this.map.getZoom();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ OpenLayers.Layer.KaMap.prototype =
|
||||
*/
|
||||
getURL: function (bounds) {
|
||||
var mapRes = this.map.getResolution();
|
||||
var scale = this.map.getScale();
|
||||
var scale = Math.round((this.map.getScale() * 10000)) / 10000;
|
||||
var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*this.tileSize.h);
|
||||
var pX = Math.round(((bounds.left) / cellSize.w) * this.tileSize.w);
|
||||
var pY = -Math.round(((bounds.top) / cellSize.h) * this.tileSize.h);
|
||||
|
||||
@@ -11,12 +11,6 @@ OpenLayers.Layer.Text = Class.create();
|
||||
OpenLayers.Layer.Text.prototype =
|
||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||
|
||||
/** Text layer is never a base layer.
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
/** store url of text file - this should be specified in the
|
||||
* "options" hashtable
|
||||
* @type str */
|
||||
|
||||
@@ -14,6 +14,12 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
/** @type VEMap */
|
||||
vemap: null,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 1,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 17,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
@@ -21,6 +27,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
initialize:function(name) {
|
||||
OpenLayers.Layer.EventPane.prototype.initialize.apply(this, arguments);
|
||||
|
||||
this.numZoomLevels = this.maxZoomLevel - this.minZoomLevel + 1;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -200,24 +208,26 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
var zoom = null;
|
||||
if (this.vemap != null) {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var veZoom = Math.floor( (Math.log(maxRes/degPerPixel)) /
|
||||
Math.log(2) );
|
||||
|
||||
//make sure zoom is within bounds
|
||||
var veZoom = Math.min(Math.max(veZoom, this.minZoomLevel),
|
||||
this.maxZoomLevel);
|
||||
|
||||
zoom = this.getOLZoomFromVEZoom(veZoom);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -245,7 +255,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getOLZoomFromVEZoom: function(veZoom) {
|
||||
var zoom = null;
|
||||
if (veZoom != null) {
|
||||
zoom = veZoom;
|
||||
zoom = veZoom - this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
@@ -260,7 +270,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
||||
getVEZoomFromOLZoom: function(olZoom) {
|
||||
var zoom = null;
|
||||
if (olZoom != null) {
|
||||
zoom = olZoom;
|
||||
zoom = olZoom + this.minZoomLevel;
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
@@ -18,6 +18,8 @@ OpenLayers.Layer.WFS.prototype =
|
||||
* @type Boolean
|
||||
*/
|
||||
isBaseLayer: false,
|
||||
|
||||
buffer: 1,
|
||||
|
||||
/** Allow the user to specify special classes for features and tiles.
|
||||
*
|
||||
@@ -157,10 +159,10 @@ OpenLayers.Layer.WFS.prototype =
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hashtable of new params to use
|
||||
* @param {Object} newParams Hashtable of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
|
||||
|
||||
|
||||
@@ -121,10 +121,10 @@ OpenLayers.Layer.WMS.prototype =
|
||||
*
|
||||
* Once params have been changed, we will need to re-init our tiles
|
||||
*
|
||||
* @param {Object} params Hashtable of new params to use
|
||||
* @param {Object} newParams Hashtable of new params to use
|
||||
*/
|
||||
mergeNewParams:function(params) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(params);
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,
|
||||
newArguments);
|
||||
|
||||
@@ -177,8 +177,11 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
* @param {Object} newParams
|
||||
*/
|
||||
mergeNewParams:function(newParams) {
|
||||
var upperParams = OpenLayers.Util.upperCaseObject(newParams);
|
||||
var newArguments = [upperParams];
|
||||
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
|
||||
arguments);
|
||||
newArguments);
|
||||
//redraw
|
||||
this.moveTo();
|
||||
},
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ OpenLayers.Layer.WorldWind.prototype =
|
||||
|
||||
zoomLevels: null,
|
||||
|
||||
initialize: function(name, url, lzd, zoomLevels, params) {
|
||||
initialize: function(name, url, lzd, zoomLevels, params, options) {
|
||||
this.lzd = lzd;
|
||||
this.zoomLevels = zoomLevels;
|
||||
var newArguments = new Array();
|
||||
newArguments.push(name, url, params);
|
||||
newArguments.push(name, url, params, options);
|
||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||
this.params = (params ? params : {});
|
||||
if (arguments.length > 0 && params) {
|
||||
|
||||
+62
-95
@@ -78,33 +78,38 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// Options
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
|
||||
/** @type String */
|
||||
projection: "EPSG:4326",
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** default max is 360 deg / 256 px, which corresponds to
|
||||
* zoom level 0 on gmaps
|
||||
*
|
||||
* @type float */
|
||||
maxResolution: 1.40625,
|
||||
|
||||
/** @type int */
|
||||
minZoomLevel: 0,
|
||||
|
||||
/** @type int */
|
||||
maxZoomLevel: 16,
|
||||
/** @type float */
|
||||
minResolution: null,
|
||||
|
||||
/** @type OpenLayers.Size */
|
||||
tileSize: null,
|
||||
/** @type float */
|
||||
maxScale: null,
|
||||
|
||||
/** @type String */
|
||||
units: 'degrees',
|
||||
|
||||
/** @type Float */
|
||||
/** @type float */
|
||||
minScale: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
maxExtent: null,
|
||||
|
||||
/** @type OpenLayers.Bounds */
|
||||
minExtent: null,
|
||||
|
||||
/** @type int */
|
||||
numZoomLevels: 16,
|
||||
|
||||
|
||||
/**
|
||||
@@ -129,6 +134,8 @@ OpenLayers.Map.prototype = {
|
||||
// the layerContainerDiv is the one that holds all the layers
|
||||
id = div.id + "_OpenLayers_Container";
|
||||
this.layerContainerDiv = OpenLayers.Util.createDiv(id);
|
||||
this.layerContainerDiv.style.zIndex=this.Z_INDEX_BASE['Popup']-1;
|
||||
|
||||
this.viewPortDiv.appendChild(this.layerContainerDiv);
|
||||
|
||||
this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
|
||||
@@ -148,7 +155,7 @@ OpenLayers.Map.prototype = {
|
||||
Event.observe(window, 'resize',
|
||||
this.updateSize.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
|
||||
//set the default options
|
||||
this.setOptions(options);
|
||||
|
||||
@@ -207,16 +214,6 @@ OpenLayers.Map.prototype = {
|
||||
// now add the options declared by the user
|
||||
// (these will override defaults)
|
||||
Object.extend(this, options);
|
||||
|
||||
// if maxResolution is specified as "auto", calculate it
|
||||
// based on the maxExtent and the viewSize
|
||||
//
|
||||
if (this.maxResolution == "auto" || this.maxResolution == null) {
|
||||
var maxExtent = this.getMaxExtent();
|
||||
var viewSize = this.getSize();
|
||||
this.maxResolution = Math.max(maxExtent.getWidth() / viewSize.w,
|
||||
maxExtent.getHeight() / viewSize.h );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -374,9 +371,12 @@ OpenLayers.Map.prototype = {
|
||||
if (center != null) {
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
if (zoom > this.baseLayer.numZoomLevels - 1) {
|
||||
zoom = this.baseLayer.numZoomLevels - 1;
|
||||
}
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
}
|
||||
|
||||
if ((noEvent == null) || (noEvent == false)) {
|
||||
this.events.triggerEvent("changebaselayer");
|
||||
}
|
||||
@@ -470,14 +470,18 @@ OpenLayers.Map.prototype = {
|
||||
if (oldSize == null)
|
||||
this.size = oldSize = newSize;
|
||||
if (!newSize.equals(oldSize)) {
|
||||
// move the layer container so that the map is still centered
|
||||
var dx = (newSize.w - oldSize.w) / 2,
|
||||
dy = (newSize.h - oldSize.h) / 2;
|
||||
var lcStyle = this.layerContainerDiv.style;
|
||||
lcStyle.left = (parseInt(lcStyle.left) + dx) + "px";
|
||||
lcStyle.top = (parseInt(lcStyle.top ) + dy) + "px";
|
||||
// reset the map center
|
||||
this.layerContainerOrigin = this.center.clone();
|
||||
|
||||
//notify layers of mapresize
|
||||
for(var i=0; i < this.layers.length; i++) {
|
||||
this.layers[i].onMapResize();
|
||||
}
|
||||
|
||||
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
|
||||
|
||||
var zoom = this.getZoom();
|
||||
this.zoom = null;
|
||||
this.setCenter(center, zoom);
|
||||
|
||||
// store the new size
|
||||
this.size = newSize;
|
||||
// the div might have moved on the page, also
|
||||
@@ -561,7 +565,6 @@ OpenLayers.Map.prototype = {
|
||||
* trigger movestart/end events
|
||||
*/
|
||||
setCenter: function (lonlat, zoom, minor) {
|
||||
|
||||
var zoomChanged = (this.isValidZoomLevel(zoom)) &&
|
||||
(zoom != this.getZoom());
|
||||
|
||||
@@ -598,7 +601,7 @@ OpenLayers.Map.prototype = {
|
||||
this.popups[i].updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//send the move call to the baselayer and all the overlays
|
||||
var bounds = this.getExtent();
|
||||
for (var i = 0; i < this.layers.length; i++) {
|
||||
@@ -643,8 +646,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
isValidZoomLevel: function(zoomLevel) {
|
||||
return ( (zoomLevel != null) &&
|
||||
(zoomLevel >= this.getMinZoomLevel()) &&
|
||||
(zoomLevel <= this.getMaxZoomLevel()) );
|
||||
(zoomLevel >= 0) &&
|
||||
(zoomLevel < this.getNumZoomLevels()) );
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -680,15 +683,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getProjection: function() {
|
||||
var projection = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
projection = this.baseLayer.getProjection();
|
||||
}
|
||||
|
||||
if (projection == null) {
|
||||
projection = this.projection;
|
||||
}
|
||||
|
||||
return projection;
|
||||
},
|
||||
|
||||
@@ -698,15 +695,9 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxResolution: function() {
|
||||
var maxResolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxResolution = this.baseLayer.getMaxResolution();
|
||||
}
|
||||
|
||||
if (maxResolution == null) {
|
||||
maxResolution = this.maxResolution;
|
||||
}
|
||||
|
||||
return maxResolution;
|
||||
},
|
||||
|
||||
@@ -715,55 +706,25 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getMaxExtent: function () {
|
||||
var maxExtent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
maxExtent = this.baseLayer.getMaxExtent();
|
||||
}
|
||||
|
||||
if (maxExtent == null) {
|
||||
maxExtent = this.maxExtent;
|
||||
}
|
||||
|
||||
}
|
||||
return maxExtent;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The maximum zoom level that can be reached in the map
|
||||
* @returns The total number of zoom levels that can be displayed by the
|
||||
* current baseLayer.
|
||||
* @type int
|
||||
*/
|
||||
getMaxZoomLevel: function() {
|
||||
var maxZoomLevel = null;
|
||||
|
||||
getNumZoomLevels: function() {
|
||||
var numZoomLevels = null;
|
||||
if (this.baseLayer != null) {
|
||||
maxZoomLevel = this.baseLayer.getMaxZoomLevel();
|
||||
numZoomLevels = this.baseLayer.getNumZoomLevels();
|
||||
}
|
||||
|
||||
if (maxZoomLevel == null) {
|
||||
maxZoomLevel = this.maxZoomLevel;
|
||||
}
|
||||
|
||||
return maxZoomLevel;
|
||||
return numZoomLevels;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns The minimum zoom level that can be reached in the map
|
||||
* @type int
|
||||
*/
|
||||
getMinZoomLevel: function() {
|
||||
var minZoomLevel = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
minZoomLevel = this.baseLayer.getMinZoomLevel();
|
||||
}
|
||||
|
||||
if (minZoomLevel == null) {
|
||||
minZoomLevel = this.minZoomLevel;
|
||||
}
|
||||
|
||||
return minZoomLevel;
|
||||
},
|
||||
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Baselayer Functions */
|
||||
@@ -783,7 +744,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getExtent: function () {
|
||||
var extent = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
extent = this.baseLayer.getExtent();
|
||||
}
|
||||
@@ -797,7 +757,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getResolution: function () {
|
||||
var resolution = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
resolution = this.baseLayer.getResolution();
|
||||
}
|
||||
@@ -811,9 +770,8 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getScale: function () {
|
||||
var scale = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
var res = this.baseLayer.getResolution();
|
||||
var res = this.getResolution();
|
||||
var units = this.baseLayer.units;
|
||||
scale = res * OpenLayers.INCHES_PER_UNIT[units] *
|
||||
OpenLayers.DOTS_PER_INCH;
|
||||
@@ -831,7 +789,6 @@ OpenLayers.Map.prototype = {
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
zoom = null;
|
||||
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForExtent(bounds);
|
||||
}
|
||||
@@ -853,7 +810,9 @@ OpenLayers.Map.prototype = {
|
||||
* @param {int} zoom
|
||||
*/
|
||||
zoomTo: function(zoom) {
|
||||
this.setCenter(null, zoom);
|
||||
if (this.isValidZoomLevel(zoom)) {
|
||||
this.setCenter(null, zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -927,7 +886,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getLonLatFromViewPortPx: function (viewPortPx) {
|
||||
return this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
var lonlat = null;
|
||||
if (this.baseLayer != null) {
|
||||
lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -940,7 +903,11 @@ OpenLayers.Map.prototype = {
|
||||
* @private
|
||||
*/
|
||||
getViewPortPxFromLonLat: function (lonlat) {
|
||||
return this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
var px = null;
|
||||
if (this.baseLayer != null) {
|
||||
px = this.baseLayer.getViewPortPxFromLonLat(lonlat);
|
||||
}
|
||||
return px;
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ OpenLayers.Tile.Image.prototype =
|
||||
*/
|
||||
clear: function() {
|
||||
OpenLayers.Tile.prototype.clear.apply(this, arguments);
|
||||
this.imgDiv.style.display = "none";
|
||||
if(this.imgDiv) {
|
||||
this.imgDiv.style.display = "none";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,8 +79,8 @@ OpenLayers.Tile.WFS.prototype =
|
||||
if (this.urls != null) {
|
||||
|
||||
for(var i=0; i < this.urls.length; i++) {
|
||||
var params = { BBOX:bounds.toBBOX() };
|
||||
var url = this.urls[i] +
|
||||
var params = { BBOX:this.bounds.toBBOX() };
|
||||
var url = this.urls[i] + "&" +
|
||||
OpenLayers.Util.getParameterString(params);
|
||||
OpenLayers.loadURL(url, null, this, success, failure);
|
||||
}
|
||||
|
||||
@@ -355,6 +355,8 @@ OpenLayers.Util.getXmlNodeValue = function(node) {
|
||||
Try.these(
|
||||
function() {
|
||||
val = node.text;
|
||||
if (!val)
|
||||
val = node.textContent;
|
||||
},
|
||||
function() {
|
||||
val = node.textContent;
|
||||
|
||||
Reference in New Issue
Block a user