new layerswitcher, improved google layer, boxes layer, grid fix

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1096 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-08-08 18:20:24 +00:00
parent 138d22af3f
commit f3a072b151
38 changed files with 1474 additions and 353 deletions
+45
View File
@@ -0,0 +1,45 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
// @require: OpenLayers/Layer.js
// @require: OpenLayers/Layer/Markers.js
/**
* @class
*/
OpenLayers.Layer.Boxes = Class.create();
OpenLayers.Layer.Boxes.prototype =
Object.extend( new OpenLayers.Layer.Markers(), {
initialize: function () {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
},
/** Calculate the pixel location for the marker, create it, and
* add it to the layer's div
*
* @private
*
* @param {OpenLayers.Marker.Box} marker
*/
drawMarker: function(marker) {
var bounds = marker.bounds;
var topleft = this.map.getLayerPxFromLonLat(
new OpenLayers.LonLat(bounds.left, bounds.top));
var botright = this.map.getLayerPxFromLonLat(
new OpenLayers.LonLat(bounds.right, bounds.bottom));
if (botright == null || topleft == null) {
marker.display(false);
} else {
var sz = new OpenLayers.Size(
botright.x - topleft.x, botright.y - topleft.y);
var markerDiv = marker.draw(topleft, sz);
if (!marker.drawn) {
this.div.appendChild(markerDiv);
marker.drawn = true;
}
}
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.Boxes"
});
+6 -9
View File
@@ -10,6 +10,11 @@ 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,
@@ -41,15 +46,7 @@ OpenLayers.Layer.GeoRSS.prototype =
this.features = null;
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
},
/** WFS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return false;
},
/**
* @param {?} ajaxRequest
*/
+42 -24
View File
@@ -37,14 +37,27 @@ if (typeof GMap2 != "undefined") {
OpenLayers.Layer.Google = Class.create();
OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
/** Google layer is always base layer
*
* @type Boolean
*/
isBaseLayer: true,
/** @type Boolean */
isFixed: true,
/** @type GMap2 gmap stores the Google Map element */
gmap:null,
/** @type GMapType */
type: null,
/** @type Boolean */
dragging:false,
/** @type Boolean */
dontListen:false,
// OPTIONS
@@ -82,19 +95,13 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
setMap:function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
// once our layer has been added to the map, we can create the vemap
this.map.events.register("addlayer", this, this.loadGMap);
// once our layer has been added to the map, we can load it
this.loadGMap();
},
/** Google layer is a base class if the GMap loaded correctly.
* @type Boolean
*/
isBaseLayer: function() {
return (this.gmap != null);
},
/** Assuming we are not dragging (in which case GMaps moving itself)
* we need to move the gmap to the new center/zoom
/** Assuming we are not dragging (in which case GMaps is moving itself,
* and the dragging flag is set) we need to move the gmap to the
* new center/zoom
*
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged
@@ -117,9 +124,16 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
if ( (!newCenter.equals(currentCenter)) ||
(newZoom != currentZoom) ) {
this.dontListen = true;
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),
this.getGZoomFromOLZoom(newZoom));
if (this.type != null) {
this.gmap.setMapType(this.type);
this.type = null;
}
this.dontListen = false;
}
}
}
@@ -136,11 +150,12 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
//has gmaps library has been loaded?
try {
// create GMap, hide nav controls
this.gmap = new GMap2(this.div);
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
GEvent.addListener(this.gmap,
"moveend",
@@ -240,14 +255,17 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
* @param {event} e
*/
catchPanZoom: function(e) {
if (!this.dontListen) {
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
var olZoom = this.getOLZoomFromGZoom(gZoom);
this.map.setCenter(olCenter, olZoom);
var gCenter = this.gmap.getCenter();
var gZoom = this.gmap.getZoom();
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
var olZoom = this.getOLZoomFromGZoom(gZoom);
this.map.setCenter(olCenter, olZoom, this.dragging);
}
},
@@ -338,7 +356,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
getOLZoomFromGZoom: function(gZoom) {
var zoom = null;
if (gZoom != null) {
zoom = gZoom - 1;
zoom = gZoom;
}
return zoom;
},
@@ -353,7 +371,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
getGZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + 1;
zoom = olZoom;
}
return zoom;
},
+1 -1
View File
@@ -136,7 +136,7 @@ OpenLayers.Layer.Grid.prototype =
*/
moveTo:function(bounds, zoomChanged, minor) {
if (bounds == null) {
bounds = this.map.getBounds();
bounds = this.map.getExtent();
}
if (bounds != null) {
if (!this.getVisibility()) {
+8 -4
View File
@@ -10,7 +10,13 @@ OpenLayers.Layer.KaMap = Class.create();
OpenLayers.Layer.KaMap.prototype =
Object.extend( new OpenLayers.Layer.Grid(), {
/** KaMap Layer is always a base layer
*
* @type Boolean
*/
isBaseLayer: true,
units: 'degrees',
scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},
@@ -118,9 +124,7 @@ OpenLayers.Layer.KaMap.prototype =
} while(tileoffsetlat > bounds.bottom - tilelat)
},
isBaseLayer: function() {
return true;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.KaMap"
});
+20 -11
View File
@@ -9,6 +9,12 @@ OpenLayers.Layer.Markers = Class.create();
OpenLayers.Layer.Markers.prototype =
Object.extend( new OpenLayers.Layer(), {
/** Markers layer is never a base layer.
*
* @type Boolean
*/
isBaseLayer: false,
/** internal marker list
* @type Array(OpenLayers.Marker) */
markers: null,
@@ -44,17 +50,18 @@ OpenLayers.Layer.Markers.prototype =
this.redraw();
}
},
/** WFS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return false;
},
/**
* @param {OpenLayers.Marker} marker
*/
*/
reproject:function() {
this.redraw();
},
/**
* @param {OpenLayers.Marker} marker
*/
addMarker: function(marker) {
this.markers.append(marker);
if (this.map && this.map.getExtent()) {
@@ -103,7 +110,9 @@ OpenLayers.Layer.Markers.prototype =
*/
drawMarker: function(marker) {
var px = this.map.getLayerPxFromLonLat(marker.lonlat);
if (px != null) {
if (px == null) {
marker.display(false);
} else {
var markerImg = marker.draw(px);
if (!marker.drawn) {
this.div.appendChild(markerImg);
+6 -7
View File
@@ -10,6 +10,12 @@ 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" hash
* @type str */
location:null,
@@ -44,13 +50,6 @@ OpenLayers.Layer.Text.prototype =
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
},
/** Text layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return false;
},
/**
* @param {?} ajaxRequest
+10 -11
View File
@@ -11,6 +11,12 @@ OpenLayers.Layer.VirtualEarth = Class.create();
OpenLayers.Layer.VirtualEarth.prototype =
Object.extend( new OpenLayers.Layer(), {
/** Virtual Earth layer is always a base layer.
*
* @type Boolean
*/
isBaseLayer: true,
/** @type Boolean */
isFixed: true,
@@ -32,15 +38,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
setMap:function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
// once our layer has been added to the map, we can create the vemap
this.map.events.register("addlayer", this, this.loadVEMap);
},
/** Virtual Earth layer is always a base class.
* @type Boolean
*/
isBaseLayer: function() {
return true;
// once our layer has been added to the map, we can load the vemap
this.loadVEMap();
},
/**
@@ -257,7 +256,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getOLZoomFromVEZoom: function(veZoom) {
var zoom = null;
if (veZoom != null) {
zoom = veZoom - 1;
zoom = veZoom;
}
return zoom;
},
@@ -272,7 +271,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
getVEZoomFromOLZoom: function(olZoom) {
var zoom = null;
if (olZoom != null) {
zoom = olZoom + 1;
zoom = olZoom;
}
return zoom;
},
+13 -8
View File
@@ -11,6 +11,12 @@ OpenLayers.Layer.WFS.prototype =
Object.extend(new OpenLayers.Layer.Grid(),
Object.extend(new OpenLayers.Layer.Markers(), {
/** WFS layer is never a base layer.
*
* @type Boolean
*/
isBaseLayer: false,
/** Allow the user to specify special classes for features and tiles.
*
* This allows for easy-definition of behaviour. The defaults are
@@ -47,6 +53,12 @@ OpenLayers.Layer.WFS.prototype =
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
var newArguments = new Array();
if (arguments.length > 0) {
//uppercase params
newArguments.push(name, options);
}
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) {
@@ -83,14 +95,7 @@ OpenLayers.Layer.WFS.prototype =
OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
},
/** WFS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return false;
},
/**
* @param {Object} obj
*
+9 -9
View File
@@ -18,6 +18,14 @@ OpenLayers.Layer.WMS.prototype =
format: "image/jpeg"
},
/** WMS layer by default is a base layer.
* If the user wishes to use a WMS as a datalayer, s/he needs only
* set this property to false.
*
* @type Boolean
*/
isBaseLayer: true,
/**
* @constructor
*
@@ -74,15 +82,7 @@ OpenLayers.Layer.WMS.prototype =
return obj;
},
/** WMS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return (this.params.TRANSPARENT != 'true');
},
/**
* addTile creates a tile, initializes it, and
* adds it to the layer div.
+6 -8
View File
@@ -20,6 +20,12 @@ OpenLayers.Layer.WMS.Untiled.prototype =
format: "image/jpeg"
},
/** WMS.Untiled layer is never a base layer.
* @type Boolean
*/
isBaseLayer: false,
/** @type DOMElement */
imgDiv: null,
@@ -81,14 +87,6 @@ OpenLayers.Layer.WMS.Untiled.prototype =
},
/** WFS layer is never a base class.
* @type Boolean
*/
isBaseLayer: function() {
return false; //(this.params.TRANSPARENT != true);
},
/** Once HTTPRequest has set the map, we can load the image div
*
* @param {OpenLayers.Map} map
+7 -3
View File
@@ -12,6 +12,12 @@ OpenLayers.Layer.WorldWind.prototype =
DEFAULT_PARAMS: {
},
/** WorldWind layer is always a base layer
*
* @type Boolean
*/
isBaseLayer: true,
// LevelZeroTileSizeDegrees
lzd: null,
@@ -55,9 +61,7 @@ OpenLayers.Layer.WorldWind.prototype =
return tile;
}
},
isBaseLayer: function() {
return true;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WorldWind"
});
+6 -7
View File
@@ -12,6 +12,12 @@ document.write("<script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzu
OpenLayers.Layer.Yahoo = Class.create();
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
/** Yahoo layer is always a base layer.
*
* @type Boolean
*/
isBaseLayer: true,
/** @type Boolean */
isFixed: true,
@@ -40,13 +46,6 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
this.map.events.register("addlayer", this, this.loadYMap);
},
/** Yahoo layer is always a base class.
* @type Boolean
*/
isBaseLayer: function() {
return true;
},
/**
* @param {OpenLayers.Bounds} bounds
* @param {Boolean} zoomChanged