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

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;
},