diff --git a/examples/google-static.html b/examples/google-static.html new file mode 100644 index 0000000000..e7e7885397 --- /dev/null +++ b/examples/google-static.html @@ -0,0 +1,33 @@ + + + + + + + OpenLayers Google (Static Maps API) Grid Layer Example + + + + +

Google (Static Maps API) Grid Layer Example

+
+ Google, grid, static, GMaps +
+

+ Using the Google Static Maps API with a Grid Layer. +

+
+
+

+ A Grid layer with a custom getURL method can be + used to request static maps for a specific extent and zoom + level. The Google Static Maps API is the most reliable way to + get Google base maps in OpenLayers. Note, however, that this is + limited to 1000 page views per viewer. Every map center or zoom + level change increases the page view counter by 1. +

+
+ + + + diff --git a/examples/google-static.js b/examples/google-static.js new file mode 100644 index 0000000000..dde0903ea8 --- /dev/null +++ b/examples/google-static.js @@ -0,0 +1,48 @@ +var options = { + singleTile: true, + ratio: 1, + isBaseLayer: true, + wrapDateLine: true, + getURL: function() { + var center = this.map.getCenter().transform("EPSG:3857", "EPSG:4326"), + size = this.map.getSize(); + return [ + this.url, "¢er=", center.lat, ",", center.lon, + "&zoom=", this.map.getZoom(), "&size=", size.w, "x", size.h + ].join(""); + } +}; + +var map = new OpenLayers.Map({ + div: "map", + maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34], + maxResolution: 156543.03390625, + units: "m", + projection: "EPSG:3857", + numZoomLevels: 22, + layers: [ + new OpenLayers.Layer.Grid( + "Google Physical", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=terrain", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Streets", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=roadmap", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Hybrid", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=hybrid", + null, options + ), + new OpenLayers.Layer.Grid( + "Google Satellite", + "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite", + null, options + ) + ], + center: new OpenLayers.LonLat(10.2, 48.9).transform("EPSG:4326", "EPSG:3857"), + zoom: 5 +}); +map.addControl(new OpenLayers.Control.LayerSwitcher());