From 46035298a513b95406c98368a856d790dbb88d14 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 13 May 2006 16:11:52 +0000 Subject: [PATCH] Begin work on Google Maps Layer. In order to create this layer, layer div creation has been moved into Layer.js, and the div that is created is then slotted into the right place by the map.addLayer function. (This is so that, at layer creation time, a div is available). However, it seems like Google Maps does not know how large the div is for reasons I don't yet understand, and there'se also the fact that our zoom levels differ from Google's at the moment. But it's getting there. git-svn-id: http://svn.openlayers.org/trunk/openlayers@29 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- google.html | 40 ++++++++++++++++++++++++++++++++++ lib/OpenLayers.js | 1 + lib/OpenLayers/Layer.js | 3 +++ lib/OpenLayers/Layer/Google.js | 17 +++++++++++++++ lib/OpenLayers/Map.js | 3 +-- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 google.html create mode 100644 lib/OpenLayers/Layer/Google.js diff --git a/google.html b/google.html new file mode 100644 index 0000000000..17fb22024d --- /dev/null +++ b/google.html @@ -0,0 +1,40 @@ + + + + + + + + + +

OpenLayers Example

+
+ + diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index a9047f9ec9..ecdd363d7a 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -41,6 +41,7 @@ catch(e){ "OpenLayers/Layer.js", "OpenLayers/Tile.js", "OpenLayers/Tile/Image.js", + "OpenLayers/Layer/Google.js", "OpenLayers/Layer/Grid.js", "OpenLayers/Layer/WMS.js", "OpenLayers/Control.js", diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 56119d863d..b5426f0682 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -15,6 +15,9 @@ OpenLayers.Layer.prototype = { */ initialize: function(name) { this.name = name; + this.div = OpenLayers.Util.createDiv(); + this.div.style.width="100%"; + this.div.style.height="100%"; }, /** diff --git a/lib/OpenLayers/Layer/Google.js b/lib/OpenLayers/Layer/Google.js new file mode 100644 index 0000000000..d304c5351f --- /dev/null +++ b/lib/OpenLayers/Layer/Google.js @@ -0,0 +1,17 @@ +OpenLayers.Layer.Google = Class.create(); +OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), { + // gmap stores the Google Map element + gmap:null, + initialize: function(name) { + OpenLayers.Layer.prototype.initialize.apply(this, [name]); + this.gmap = new GMap2(this.div); + }, + moveTo: function() { + center = this.map.getCenter(); + this.gmap.setCenter( + new GLatLng(center.lat, center.lon), + this.map.getZoom() + ); + } + +}); diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 767da7b8a8..23fbc04932 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -108,8 +108,7 @@ OpenLayers.Map.prototype = { */ addLayer: function (layer) { layer.map = this; - layer.div = OpenLayers.Util.createDiv(); - //layer.div.style.overflow = "hidden"; + layer.div.style.overflow = ""; layer.div.style.zIndex = this.Z_INDEX_BASE['Layer'] + this.layers.length; this.layerContainerDiv.appendChild(layer.div); this.layers.push(layer);