bringing all changes from sandbox/euzuro/LayersReworking down into the trunk. this is a merge of r656:HEAD http://svn.openlayers.org/sandbox/euzuro/LayersReworking

git-svn-id: http://svn.openlayers.org/trunk/openlayers@806 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-06-27 23:16:26 +00:00
parent 63bd624827
commit ff0e83d0a0
24 changed files with 1262 additions and 467 deletions

View File

@@ -33,31 +33,20 @@ OpenLayers.Control.KeyboardDefaults.prototype =
* @param {Event} evt
*/
defaultKeyDown: function (evt) {
var slide = this.map.getResolution() * this.slideFactor;
var center = this.map.getCenter();
var newCenter = center.copyOf();
switch(evt.keyCode) {
case Event.KEY_LEFT:
newCenter = newCenter.add( -slide, 0);
this.map.pan(-50, 0);
break;
case Event.KEY_RIGHT:
newCenter = newCenter.add( slide, 0);
this.map.pan(50, 0);
break;
case Event.KEY_UP:
newCenter = newCenter.add( 0, slide);
this.map.pan(0, -50);
break;
case Event.KEY_DOWN:
newCenter = newCenter.add( 0, -slide);
this.map.pan(0, 50);
break;
}
if (!newCenter.equals(center)) {
this.map.setCenter(newCenter);
Event.stop(evt);
}
},
/** @final @type String */

View File

@@ -113,23 +113,18 @@ OpenLayers.Control.PanZoom.prototype =
buttonDown: function (evt) {
if (!Event.isLeftClick(evt)) return;
var slide = this.map.getResolution() * this.slideFactor;
var center = this.map.getCenter();
var newCenter = center.copyOf();
switch (this.action) {
case "panup":
newCenter = newCenter.add( 0, slide);
this.map.pan(0, -50);
break;
case "pandown":
newCenter = newCenter.add( 0, -slide);
this.map.pan(0, 50);
break;
case "panleft":
newCenter = newCenter.add( -slide, 0);
this.map.pan(-50, 0);
break;
case "panright":
newCenter = newCenter.add( slide, 0);
this.map.pan(50, 0);
break;
case "zoomin":
this.map.zoomIn();
@@ -138,14 +133,10 @@ OpenLayers.Control.PanZoom.prototype =
this.map.zoomOut();
break;
case "zoomworld":
this.map.zoomToFullExtent();
this.map.zoomToMaxExtent();
break;
}
if (!newCenter.equals(center)) {
this.map.setCenter(newCenter);
}
Event.stop(evt);
},

View File

@@ -24,6 +24,10 @@ 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.
},
/**
@@ -60,7 +64,7 @@ OpenLayers.Control.PanZoomBar.prototype =
var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
var slider = OpenLayers.Util.createAlphaImageDiv(id,
centered.add(-1,
(this.map.getZoomLevels())*this.zoomStopHeight),
(this.map.getMaxZoomLevel())*this.zoomStopHeight),
new OpenLayers.Size(20,9),
imgLocation+"slider.png",
"absolute");
@@ -74,7 +78,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.sliderEvents.register("click", this, this.doubleClick);
sz = new OpenLayers.Size();
sz.h = this.zoomStopHeight*(this.map.getZoomLevels()+1);
sz.h = this.zoomStopHeight*(this.map.getMaxZoomLevel()+1);
sz.w = this.zoomStopWidth;
var div = null
@@ -110,7 +114,7 @@ OpenLayers.Control.PanZoomBar.prototype =
this.map.events.register("zoomend", this, this.moveZoomBar);
centered = centered.add(0,
this.zoomStopHeight*(this.map.getZoomLevels()+1));
this.zoomStopHeight*(this.map.getMaxZoomLevel()+1));
return centered;
},
/*
@@ -131,7 +135,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.getZoomLevels() - levels);
this.map.zoomTo(this.map.getMaxZoomLevel() - levels);
Event.stop(evt);
},
@@ -193,7 +197,7 @@ OpenLayers.Control.PanZoomBar.prototype =
*/
moveZoomBar:function() {
var newTop =
(this.map.getZoomLevels() - this.map.getZoom()) * this.zoomStopHeight
(this.map.getMaxZoomLevel() - this.map.getZoom()) * this.zoomStopHeight
+ this.startTop + 1;
this.slider.style.top = newTop + "px";
},

View File

@@ -53,7 +53,7 @@ OpenLayers.Icon.prototype = {
* @type OpenLayers.Icon
*/
clone: function() {
return new OpenLayers.Icon(this.size, this.url, this.offset);
return new OpenLayers.Icon(this.url, this.size, this.offset);
},
/**

View File

@@ -13,17 +13,43 @@ OpenLayers.Layer.prototype = {
/** @type DOMElement */
div: null,
/** This variable is set in map.addLayer, not within the layer itself
* @type OpenLayers.Map */
/** This variable is set when the layer is added to the map, via the
* accessor function setMap()
*
* @type OpenLayers.Map */
map: null,
// OPTIONS
/** @type String */
projection: null,
/** @type OpenLayers.Bounds */
maxExtent: null,
/** @type float */
maxResolution: null,
/** @type int */
minZoomLevel: null,
/** @type int */
maxZoomLevel: null,
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name) {
initialize: function(name, options) {
if (arguments.length > 0) {
//add options to layer
Object.extend(this, options);
this.name = name;
if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
@@ -46,14 +72,17 @@ OpenLayers.Layer.prototype = {
/**
* @params {OpenLayers.Bounds} bound
* @params {Boolean} zoomChanged tells when zoom has changed, as layers have to do some init work in that case.
* @params {Boolean} zoomChanged tells when zoom has changed, as layers
* have to do some init work in that case.
*/
moveTo: function (bound, zoomChanged) {
// not implemented here
return;
//this function should be implemented by all subclasses.
},
/**
/** Set the map property for the layer. This is done through an accessor
* so that subclasses can override this and take special action once
* they have their map variable set.
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
@@ -62,11 +91,12 @@ OpenLayers.Layer.prototype = {
/**
* @returns Whether or not the layer is a base layer. This should be
* determined individually by all subclasses.
* determined individually by all subclasses. Default is false
* @type Boolean
*/
isBaseLayer: function() {
//this function should be implemented by all subclasses.
//this function should be implemented by all subclasses.
return false;
},
/**
@@ -87,6 +117,158 @@ OpenLayers.Layer.prototype = {
}
},
/********************************************************/
/* */
/* Layer Options */
/* */
/* Accessor functions to Layer Options parameters */
/* */
/********************************************************/
/**
* @type String
*/
getProjection: function() {
return this.projection;
},
/**
* @type OpenLayers.Bounds
*/
getMaxExtent: function() {
return this.maxExtent;
},
/**
* @type float
*/
getMaxResolution: function() {
return this.maxResolution;
},
/**
* @returns The minimum zoom level that can be reached in this layer
* @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;
},
/********************************************************/
/* */
/* Baselayer Functions */
/* */
/* The following functions must all be implemented */
/* by all base layers */
/* */
/********************************************************/
/**
* @returns Degrees per Pixel
* @type float
*/
getResolution: function() {
var viewSize = this.map.getSize();
var extent = this.map.getExtent();
return Math.max( extent.getWidth() / viewSize.w,
extent.getHeight() / viewSize.h );
},
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by the layer
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var size = this.map.getSize();
var center = this.map.getCenter(); //map center lon/lat
var res = this.map.getResolution();
var delta_x = viewPortPx.x - (size.w / 2);
var delta_y = viewPortPx.y - (size.h / 2);
return new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var resolution = this.map.getResolution();
var extent = this.map.getExtent();
return new OpenLayers.Pixel(
Math.round(1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat))
);
},
/**
* @param {OpenLayers.Bounds} bounds
*
* @return {int}
*/
getZoomForExtent: function (bounds) {
// this should be implemented by subclasses
},
/**
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
// this should be implemented by subclasses
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;
return 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;
/** ALT CALCULATION FOR GETEXTENT
var size = this.getSize();
var tlPx = new OpenLayers.Pixel(0,0);
var tlLL = this.getLonLatFromViewPortPx(tlPx);
var brPx = new OpenLayers.Pixel(size.w, size.h);
var brLL = this.getLonLatFromViewPortPx(brPx);
extent = new OpenLayers.Bounds(tlLL.lon,
brLL.lat,
brLL.lon,
tlLL.lat);
**/
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer"
};

View File

@@ -14,7 +14,7 @@ OpenLayers.Layer.Google = Class.create();
OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
/** @type Boolean */
viewPortLayer: true,
isFixed: true,
/** @type GMap2 gmap stores the Google Map element */
gmap:null,
@@ -27,8 +27,18 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
*
* @param {String} name
*/
initialize: function(name) {
OpenLayers.Layer.prototype.initialize.apply(this, [name]);
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
if (this.minZoomLevel == null) {
this.minZoomLevel = -1;
}
if (this.maxZoomLevel == null) {
this.maxZoomLevel = 16;
}
if (this.maxExtent == null) {
this.maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
}
},
/**
@@ -50,21 +60,29 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
/**
* @param {OpenLayers.Bounds} bounds
* @param {int} zoomChanged
* @param {Boolean} zoomChanged
*/
moveTo:function(bounds,zoomChanged) {
moveTo:function(bounds, zoomChanged) {
if ((this.gmap != null) && (!this.dragging)) {
var olCenter = this.map.getCenter();
var gCenter = this.getGMapCenter();
var olZoom = this.map.getZoom();
var gZoom = this.gmap.getZoom();
if ((!olCenter.equals(gCenter)) || ((olZoom +1) != gZoom)) {
this.gmap.setCenter(new GLatLng(olCenter.lat, olCenter.lon),
olZoom + 1);
var newCenter = this.map.getCenter();
var newZoom = this.map.getZoom();
if (newCenter != null) {
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
var currentCenter = this.getOLLonLatFromGLatLng(gCenter);
var currentZoom = this.getOLZoomFromGZoom(gZoom);
if ( (!newCenter.equals(currentCenter)) ||
(newZoom != currentZoom) ) {
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),
this.getGZoomFromOLZoom(newZoom));
}
}
}
},
@@ -73,6 +91,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
*
*/
loadGMap:function() {
// create div and set to same size as map
var gDiv = OpenLayers.Util.createDiv(this.name);
var sz = this.map.getSize();
@@ -82,6 +101,8 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
// create GMap, hide nav controls
this.gmap = new GMap2(this.div);
// this causes the GMap to set itself to Map's center/zoom
this.moveTo();
// catch pans and zooms from GMap
@@ -101,6 +122,11 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
"dragend",
this.dragEnd.bindAsEventListener(this));
// catch pans and zooms from GMap
GEvent.addListener(this.gmap,
"drag",
this.catchPanZoom.bindAsEventListener(this));
},
/**
@@ -123,30 +149,209 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
* @param {event} e
*/
catchPanZoom: function(e) {
var olCenter = this.getGMapCenter();
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
this.map.setCenter(olCenter, gZoom - 1);
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
var olZoom = this.getOLZoomFromGZoom(gZoom);
this.map.setCenter(olCenter, olZoom);
},
/**
* @param {OpenLayers.Pixel} viewPortPx
*
* @returns An OpenLayers.LonLat which is the passed-in view port
* OpenLayers.Pixel, translated into lon/lat by GMAPS
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var gPoint = this.getGPointFromOLPixel(viewPortPx);
var gLatLng = this.gmap.fromDivPixelToLatLng(gPoint)
return this.getOLLonLatFromGLatLng(gLatLng);
},
/**
* @param {OpenLayers.LonLat} lonlat
*
* @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
* translated into view port pixels BY GMAPS
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var gLatLng = this.getGLatLngFromOLLonLat(lonlat);
var gPoint = this.gmap.fromLatLngToDivPixel(gLatLng)
return this.getOLPixelFromGPoint(gPoint);
},
/**
* @private
* @param {OpenLayers.Bounds} bounds
*
* @return {int}
*/
getZoomForExtent: function (bounds) {
var gBounds = this.getGLatLngBoundsFromOLBounds(bounds);
var gZoom = this.gmap.getBoundsZoomLevel(gBounds);
return this.getOLZoomFromGZoom(gZoom);
},
/**
* @returns A Bounds object which represents the lon/lat bounds of the
* current viewPort.
* @type OpenLayers.Bounds
*/
getExtent: function () {
if (this.gmap.getCenter() == null) {
this.moveTo();
}
var gLatLngBounds = this.gmap.getBounds();
return this.getOLBoundsFromGLatLngBounds(gLatLngBounds);
},
/********************************************************/
/* */
/* Translation Functions */
/* */
/* The following functions translate GMaps and OL */
/* formats for Pixel, LonLat, Bounds, and Zoom */
/* */
/********************************************************/
//
// TRANSLATION: GZoom <-> OpenLayers Zoom
//
/**
* @param {int} gZoom
*
* @returns An OpenLayers.LonLat with the center of the gmap, or null if
* the GMap has not been centered yet
* @returns An OpenLayers Zoom level, translated from the passed in gZoom
* @type int
*/
getOLZoomFromGZoom: function(gZoom) {
return (gZoom - 1);
},
/**
* @param {int} olZoom
*
* @returns A GZoom level, translated from the passed in olZoom
* @type int
*/
getGZoomFromOLZoom: function(olZoom) {
return (olZoom + 1);
},
//
// TRANSLATION: GLatLng <-> LonLat
//
/**
* @param {GLatLng} gLatLng
*
* @returns An OpenLayers.LonLat, translated from the passed in GLatLng
* @type OpenLayers.LonLat
*/
getGMapCenter:function() {
var olCenter = null;
var gCenter = this.gmap.getCenter();
if (gCenter != null) {
olCenter = new OpenLayers.LonLat(gCenter.lng(), gCenter.lat());
getOLLonLatFromGLatLng: function(gLatLng) {
var olLonLat = null;
if (gLatLng != null) {
olLonLat = new OpenLayers.LonLat(gLatLng.lng(), gLatLng.lat());
}
return olCenter;
return olLonLat;
},
/**
* @param {OpenLayers.LonLat} olLonLat
*
* @returns A GLatLng, translated from the passed in OpenLayers.LonLat
* @type GLatLng
*/
getGLatLngFromOLLonLat: function(olLonLat) {
var gLatLng = null;
if (olLonLat != null) {
gLatLng = new GLatLng(olLonLat.lat, olLonLat.lon);
}
return gLatLng;
},
//
// TRANSLATION: GPoint <-> OpenLayers.Pixel
//
/**
* @param {GPoint} gPoint
*
* @returns An OpenLayers.Pixel, translated from the passed in GPoint
* @type OpenLayers.Pixel
*/
getOLPixelFromGPoint: function(gPoint) {
var olPixel = null;
if (gPoint != null) {
olPixel = new OpenLayers.Pixel(gPoint.x, gPoint.y);
}
return olPixel;
},
/**
* @param {OpenLayers.Pixel} olPixel
*
* @returns A GPoint, translated from the passed in OpenLayers.Pixel
* @type GPoint
*/
getGPointFromOLPixel: function(olPixel) {
var gPoint = null;
if (olPixel != null) {
gPoint = new GPoint(olPixel.x, olPixel.y);
}
return gPoint;
},
//
// TRANSLATION: GLatLngBounds <-> OpenLayers.Bounds
//
/**
* @param {GLatLngBounds} gLatLngBounds
*
* @returns An OpenLayers.Bounds, translated from gLatLngBounds
* @type OpenLayers.Bounds
*/
getOLBoundsFromGLatLngBounds: function(gLatLngBounds) {
var olBounds = null;
if (gLatLngBounds != null) {
var sw = gLatLngBounds.getSouthWest();
var ne = gLatLngBounds.getNorthEast();
olBounds = new OpenLayers.Bounds(sw.lng(),
sw.lat(),
ne.lng(),
ne.lat() );
}
return olBounds;
},
/**
* @param {OpenLayers.Bounds} olBounds
*
* @returns A GLatLngBounds, translated from olBounds
* @type GLatLngBounds
*/
getGLatLngBoundsFromOLBounds: function(olBounds) {
var gLatLngBounds = null;
if (olBounds != null) {
var sw = new GLatLng(olBounds.bottom, olBounds.left);
var ne = new GLatLng(olBounds.top, olBounds.right);
gLatLngBounds = new GLatLngBounds(sw, ne);
}
return gLatLngBounds;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Google"
});

View File

@@ -4,8 +4,6 @@
// @require: OpenLayers/Layer.js
// @require: OpenLayers/Util.js
OpenLayers.Layer.Grid = Class.create();
OpenLayers.Layer.Grid.TILE_WIDTH = 256;
OpenLayers.Layer.Grid.TILE_HEIGHT = 256;
OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
// str: url
@@ -25,17 +23,16 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
* @param {str} name
* @param {str} url
* @param {hash} params
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name, url, params) {
initialize: function(name, url, params, options) {
var newArguments = arguments;
if (arguments.length > 0) {
newArguments = [name];
newArguments = [name, options];
}
OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
this.url = url;
this.params = params;
this.tileSize = new OpenLayers.Size(OpenLayers.Layer.Grid.TILE_WIDTH,
OpenLayers.Layer.Grid.TILE_HEIGHT);
},
/**
@@ -48,18 +45,33 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
},
/** When the layer is added to a map, then we can ask the map for
* its default tile size
*
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
if (this.tileSize == null) {
this.tileSize = this.map.getTileSize();
}
},
/**
* @deprecated User should just set the 'tileSize' via options
*/
setTileSize: function (size) {
this.tileSize = size.copyOf();
},
/**
* moveTo
* moveTo is a function called whenever the map is moved. All the moving
/** 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.
*
* @param {OpenLayers.Bounds}
* @param {Boolean} zoomChanged
*/
moveTo:function(bounds,zoomChanged) {
moveTo:function(bounds, zoomChanged) {
if (!this.getVisibility()) {
if (zoomChanged) {
this.grid = null;
@@ -84,6 +96,8 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
}
}
},
getGridBounds:function() {
var topLeftTile = this.grid[0][0];
var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1];
@@ -106,7 +120,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
var viewSize = this.map.getSize();
var bounds = this.map.getExtent();
var extent = this.map.getFullExtent();
var extent = this.map.getMaxExtent();
var resolution = this.map.getResolution();
var tilelon = resolution*this.tileSize.w;
var tilelat = resolution*this.tileSize.h;
@@ -236,7 +250,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
*/
getFullRequestString:function(params) {
var requestString = "";
this.params.SRS = this.map.projection;
this.params.SRS = this.map.getProjection();
// concat tile params with layer params and convert to string
var allParams = Object.extend(this.params, params);
var paramsString = OpenLayers.Util.getParameterString(allParams);

View File

@@ -17,8 +17,9 @@ OpenLayers.Layer.Markers.prototype =
* @constructor
*
* @param {String} name
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name) {
initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
this.markers = new Array();
},

View File

@@ -10,7 +10,7 @@ OpenLayers.Layer.Text = Class.create();
OpenLayers.Layer.Text.prototype =
Object.extend( new OpenLayers.Layer.Markers(), {
/** store url of text file
/** store url of text file - this should be specified in the "options" hash
* @type str */
location:null,
@@ -25,16 +25,18 @@ OpenLayers.Layer.Text.prototype =
*
* @param {String} name
* @param {String} location
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name, location) {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]);
this.location = location;
initialize: function(name, options) {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
this.features = new Array();
new Ajax.Request(location,
{ method: 'get', onComplete:this.parseData.bind(this) } );
if (this.location != null) {
new Ajax.Request(this.location,
{ method: 'get', onComplete:this.parseData.bind(this) } );
}
},
/**
/**
*
*/
destroy: function() {
@@ -43,7 +45,7 @@ OpenLayers.Layer.Text.prototype =
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
},
/** WFS layer is never a base class.
/** Text layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {

View File

@@ -15,7 +15,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
Object.extend( new OpenLayers.Layer(), {
/** @type Boolean */
viewPortLayer: true,
isFixed: true,
/** @type VEMap */
vemap: null,
@@ -48,9 +48,9 @@ OpenLayers.Layer.VirtualEarth.prototype =
/**
* @param {OpenLayers.Bounds} bounds
* @param {int} zoomChanged
* @param {Boolean} zoomChanged
*/
moveTo:function(bounds,zoomChanged) {
moveTo:function(bounds, zoomChanged) {
if (this.vemap != null) {
var olCenter = this.map.getCenter();

View File

@@ -11,7 +11,10 @@ OpenLayers.Layer.WFS.prototype =
Object.extend(new OpenLayers.Layer.Grid(),
Object.extend(new OpenLayers.Layer.Markers(), {
/** @type Object */
/** Allow the user to specify a special class to use to display features.
* This allows for easy-definition of feature behaviour. This property
* should be set via the "options" parameter.
* @type Object */
featureClass: OpenLayers.Feature.WFS,
/** @final @type hash */
@@ -27,16 +30,14 @@ OpenLayers.Layer.WFS.prototype =
* @param {str} name
* @param {str} url
* @param {hash} params
* @param {Object} featureClass
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name, url, params, featureClass) {
if (featureClass != null) this.featureClass = featureClass;
initialize: function(name, url, params, options) {
var newArguments = new Array();
if (arguments.length > 0) {
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);

View File

@@ -24,16 +24,17 @@ OpenLayers.Layer.WMS.prototype =
* @param {str} name
* @param {str} url
* @param {hash} params
* @param {Object} options Hash of extra options to tag onto the layer
*/
initialize: function(name, url, params) {
initialize: function(name, url, params, options) {
var newArguments = new Array();
if (arguments.length > 0) {
//uppercase params
params = OpenLayers.Util.upperCaseObject(params);
newArguments.push(name, url, params);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) {
OpenLayers.Util.applyDefaults(
this.params,
@@ -43,7 +44,7 @@ OpenLayers.Layer.WMS.prototype =
},
/** WFS layer is never a base class.
/** WMS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
@@ -86,6 +87,49 @@ OpenLayers.Layer.WMS.prototype =
url, this.tileSize);
},
/**
* @returns Degrees per Pixel
* @type float
*/
getResolution: function() {
var maxRes = this.map.getMaxResolution();
var zoom = this.map.getZoom();
return maxRes / Math.pow(2, zoom);
},
/**
* @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;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WMS"
});

View File

@@ -13,7 +13,7 @@ OpenLayers.Layer.Yahoo = Class.create();
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
/** @type Boolean */
viewPortLayer: true,
isFixed: true,
/** @type GMap2 gmap stores the Google Map element */
ymap:null,
@@ -49,9 +49,9 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
/**
* @param {OpenLayers.Bounds} bounds
* @param {int} zoomChanged
* @param {Boolean} zoomChanged
*/
moveTo:function(bounds,zoomChanged) {
moveTo:function(bounds, zoomChanged) {
if ((this.ymap != null) && (!this.dragging)) {

File diff suppressed because it is too large Load Diff