Skip to content

Instantly share code, notes, and snippets.

@fvanderbiest
Last active December 14, 2015 02:49
Show Gist options
  • Save fvanderbiest/5016641 to your computer and use it in GitHub Desktop.
Save fvanderbiest/5016641 to your computer and use it in GitHub Desktop.
Google Maps in geOrchestra viewer
<?xml version="1.0"?>
<ViewContext xmlns="http://www.opengis.net/context" version="1.1.0" id="default.wmc" xsi:schemaLocation="http://www.opengis.net/context http://schemas.opengis.net/context/1.1.0/context.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<General>
<Window width="256" height="256"/>
<BoundingBox minx="-20037508.3392" miny="-20037508.3392" maxx="20037508.3392" maxy="20037508.3392" SRS="EPSG:900913"/>
<Title/>
<Extension>
<ol:maxExtent xmlns:ol="http://openlayers.org/context" minx="-20037508.3392" miny="-20037508.3392" maxx="20037508.3392" maxy="20037508.3392"/>
</Extension>
</General>
<LayerList>
</LayerList>
</ViewContext>
/**
* Constant: MAP_SCALES
* {Array} The map's scales.
* Defaults to GeoBretagne GWC compliant scales
*/
MAP_SCALES : [
846.372882141,
1692.745764282,
3385.491528564,
6770.983057129,
13541.966114258194,
27083.932228516387,
54167.864457032774,
108335.72891406555,
216671.4578281311,
433342.9156562622,
866685.8313125244,
1733371.6626250488,
3466743.3252500976,
6933486.650500195,
13866973.30100039,
27733946.60200078,
55467893.20400156,
110935786.40800312,
221871572.81600624,
443743145.63201248
],
/**
* Constant: MAP_SRS
* {String} The default map SRS code.
* Defaults to EPSG:2154
*/
MAP_SRS: "EPSG:900913",
/**
* Constant: MAP_XMIN aka "left"
* {Float} The max extent xmin in MAP_SRS coordinates.
* Defaults to -357823.2365 (EPSG:2154 left)
*/
MAP_XMIN: -128*156543.0339,
/**
* Constant: MAP_YMIN aka "bottom"
* {Float} The max extent ymin in MAP_SRS coordinates.
* Defaults to 6037008.6939 (EPSG:2154 bottom)
*/
MAP_YMIN: -128*156543.0339,
/**
* Constant: MAP_XMAX aka "right"
* {Float} The max extent xmax in MAP_SRS coordinates.
* Defaults to 1313632.3628 (EPSG:2154 right)
*/
MAP_XMAX: 128*156543.0339,
/**
* Constant: MAP_YSMAX aka "top"
* {Float} The max extent ymax in MAP_SRS coordinates
* Defaults to 7230727.3772 (EPSG:2154 top)
*/
MAP_YMAX: 128*156543.0339,
diff --git a/mapfishapp/src/main/filtered-resources/WEB-INF/jsp/index.jsp b/mapfishapp/src/main/filtered-resources/WEB-INF/jsp/index.jsp
index a346e1d..ccf90d6 100644
--- a/mapfishapp/src/main/filtered-resources/WEB-INF/jsp/index.jsp
+++ b/mapfishapp/src/main/filtered-resources/WEB-INF/jsp/index.jsp
@@ -137,6 +137,7 @@ if(sec_roles != null) {
loading custom parameters (see build profile)
-->
<script type="text/javascript" src="app/js/GEOR_custom.js"></script>
+ <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<c:choose>
<c:when test='<%= request.getParameter("debug") != null %>'>
diff --git a/mapfishapp/src/main/webapp/app/css/main.css b/mapfishapp/src/main/webapp/app/css/main.css
index 1def1c2..50330cb 100644
--- a/mapfishapp/src/main/webapp/app/css/main.css
+++ b/mapfishapp/src/main/webapp/app/css/main.css
@@ -432,4 +432,25 @@ div.olMapViewport {
/* checked menu item */
.x-menu-list .x-menu-item-checked {
font-weight: bold;
-}
\ No newline at end of file
+}
+
+/* Google in OpenLayers */
+.olLayerGoogleCopyright {
+ right: 3px;
+ bottom: 2px;
+ left: auto;
+}
+.olLayerGoogleV3.olLayerGoogleCopyright {
+ bottom: 0px;
+ right: 0px !important;
+}
+.olLayerGooglePoweredBy {
+ left: 2px;
+ bottom: 2px;
+}
+.olLayerGoogleV3.olLayerGooglePoweredBy {
+ bottom: 15px !important;
+}
+div.gmnoprint a {
+ display: none;
+}
diff --git a/mapfishapp/src/main/webapp/app/js/GEOR_map.js b/mapfishapp/src/main/webapp/app/js/GEOR_map.js
index bfadbe3..dd72725 100644
--- a/mapfishapp/src/main/webapp/app/js/GEOR_map.js
+++ b/mapfishapp/src/main/webapp/app/js/GEOR_map.js
@@ -22,6 +22,7 @@
* @include OpenLayers/Control/PinchZoom.js
* @include OpenLayers/Control/LoadingPanel.js
* @include OpenLayers/Kinetic.js
+ * @include OpenLayers/Layer/Google.js
* @include OpenLayers/Layer/WMS.js
* @include OpenLayers/Layer/XYZ.js
* @include GeoExt/data/LayerRecord.js
@@ -33,6 +34,55 @@
Ext.namespace("GEOR");
+
+// read http://trac.osgeo.org/openlayers/wiki/Release/2.11/GoogleMaps37
+OpenLayers.Layer.Google.v3.repositionMapElements = function() {
+ // This is the first time any Google layer in this mapObject has been
+ // made visible. The mapObject needs to know the container size.
+ google.maps.event.trigger(this.mapObject, "resize");
+
+ var div = this.mapObject.getDiv().firstChild;
+ if (!div || div.childNodes.length < 3) {
+ this.repositionTimer = window.setTimeout(
+ OpenLayers.Function.bind(this.repositionMapElements, this),
+ 250
+ );
+ return false;
+ }
+
+ var cache = OpenLayers.Layer.Google.cache[this.map.id];
+ var container = this.map.viewPortDiv;
+
+ // move the ToS and branding stuff up to the container div
+ // depends on value of zIndex, which is not robust
+ for (var i=div.children.length-1; i>=0; --i) {
+ if (div.children[i].style.zIndex == 1000001) {
+ var termsOfUse = div.children[i];
+ container.appendChild(termsOfUse);
+ termsOfUse.style.zIndex = "1100";
+ termsOfUse.style.bottom = "";
+ termsOfUse.className = "olLayerGoogleCopyright olLayerGoogleV3";
+ termsOfUse.style.display = "";
+ cache.termsOfUse = termsOfUse;
+ }
+ if (div.children[i].style.zIndex == 1000000) {
+ var poweredBy = div.children[i];
+ container.appendChild(poweredBy);
+ poweredBy.style.zIndex = "1100";
+ poweredBy.style.bottom = "";
+ poweredBy.className = "olLayerGooglePoweredBy olLayerGoogleV3 gmnoprint";
+ poweredBy.style.display = "";
+ cache.poweredBy = poweredBy;
+ }
+ if (div.children[i].style.zIndex == 10000002) {
+ container.appendChild(div.children[i]);
+ }
+ }
+
+ this.setGMapVisibility(this.visibility);
+};
+
+
GEOR.map = (function() {
/*
@@ -66,8 +116,11 @@ GEOR.map = (function() {
* {OpenLayers.Layer} The unique base layer in this app.
*/
var createMainBaseLayer = function() {
- return new OpenLayers.Layer("base_layer", {
- displayInLayerSwitcher: false,
+ return new OpenLayers.Layer.Google("Google Hybrid", {
+ type: google.maps.MapTypeId.HYBRID,
+ numZoomLevels: 20,
+ animationEnabled:true,
+ displayInLayerSwitcher: false,
isBaseLayer: true
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment