[Mapbender-commits] r3996 - branches/google_dev/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jun 4 04:36:32 EDT 2009
Author: christoph
Date: 2009-06-04 04:36:31 -0400 (Thu, 04 Jun 2009)
New Revision: 3996
Modified:
branches/google_dev/http/javascripts/mod_google.php
Log:
Modified: branches/google_dev/http/javascripts/mod_google.php
===================================================================
--- branches/google_dev/http/javascripts/mod_google.php 2009-06-03 16:31:49 UTC (rev 3995)
+++ branches/google_dev/http/javascripts/mod_google.php 2009-06-04 08:36:31 UTC (rev 3996)
@@ -20,61 +20,42 @@
require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
echo "var mod_google_target = '".$e_target[0]."';";
-$mapsApiUrl = "http://maps.google.com/maps/api/js?sensor=false&key=ABQIAAAAnSxy5UckGSKS1Wxnq6d10RRmYiuLful4T_-5_WDsqgKCFa5YaxSr2GxbtA92UOizu0iI4JvP_23jUw";
+require(dirname(__FILE__)."/../include/dyn_php.php");
-readfile($mapsApiUrl);
+if (!$key) {
+ $e = new mb_exception("No key given for Google Maps API. Google Maps will not be available.");
+}
-require(dirname(__FILE__)."/../include/dyn_js.php");
+$mapsApiUrl = "http://maps.google.com/maps/api/js?sensor=false&key=" . $key;
+
+readfile($mapsApiUrl);
?>
-if (typeof CENTER === "undefined") {
- var CENTER = [50.7376701, 7.0714];
-}
+mb_mapObj_const.prototype.zoomToLevel = function (currentZoomLevel) {
+ this.google.map.set_zoom(currentZoomLevel);
+
+ var that = this;
-if (typeof MAX_ZOOM_LEVEL === "undefined") {
- var MAX_ZOOM_LEVEL = 19;
-}
+ var zoomListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
+ google.maps.event.removeListener(zoomListener);
-if (typeof MIN_ZOOM_LEVEL === "undefined") {
- var MIN_ZOOM_LEVEL = 2;
-}
+ var newBounds = that.google.map.get_bounds();
+ var newSw = newBounds.getSouthWest();
+ var newNe = newBounds.getNorthEast();
-if (typeof ZOOM_LEVEL === "undefined") {
- var ZOOM_LEVEL = 10;
-}
+ that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
+ that.setMapRequest();
+ });
+};
-if (typeof TYPE === "undefined") {
- var TYPE = "SATELLITE";
-}
-
-if (typeof KEY === "undefined") {
- var e = new Mb_exception("No key for Google Maps. Please configure the element vars.");
-}
-else {
-
- mb_mapObj_const.prototype.zoomToLevel = function (currentZoomLevel) {
- this.google.map.set_zoom(currentZoomLevel);
-
- var that = this;
+mb_mapObj_const.prototype.setGoogleMap = function (options) {
+ try {
- var zoomListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
- google.maps.event.removeListener(zoomListener);
-
- var newBounds = that.google.map.get_bounds();
- var newSw = newBounds.getSouthWest();
- var newNe = newBounds.getNorthEast();
-
- that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
- that.setMapRequest();
- });
- };
-
- mb_mapObj_const.prototype.setGoogleMap = function (options) {
this.google = {
"id" : this.elementName + "-google",
- "MIN_ZOOM_LEVEL" : MIN_ZOOM_LEVEL,
- "MAX_ZOOM_LEVEL" : MAX_ZOOM_LEVEL,
+ "MIN_ZOOM_LEVEL" : options.MIN_ZOOM_LEVEL,
+ "MAX_ZOOM_LEVEL" : options.MAX_ZOOM_LEVEL,
"isInitialised" : false
};
@@ -97,17 +78,17 @@
// get center
-// THIS IS THE CENTER OF WMS 0; MAY RESULT IN A ZOOM LEVEL LIKE 0 OR 1,
-// WHICH BREAKS THE WMS BBOX
-// var latLng = new google.maps.LatLng(this.extent.center.y, this.extent.center.x);
+ // THIS IS THE CENTER OF WMS 0; MAY RESULT IN A ZOOM LEVEL LIKE 0 OR 1,
+ // WHICH BREAKS THE WMS BBOX
+ // var latLng = new google.maps.LatLng(this.extent.center.y, this.extent.center.x);
// USE THIS CENTER FOR TESTING!!!!!!!
- var latLng = new google.maps.LatLng(CENTER[0], CENTER[1]);
+ var latLng = new google.maps.LatLng(options.CENTER[0], options.CENTER[1]);
// calculate zoom level from extent after initialization
var temporaryOptions = {
- zoom : ZOOM_LEVEL,
+ zoom : options.ZOOM_LEVEL,
center : latLng
};
@@ -129,7 +110,7 @@
that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
that.google.map.isInitialised = true;
-
+
that.setMapRequest();
});
@@ -141,39 +122,67 @@
"height" : that.height + "px"
});
});
+ }
+ catch (e) {
+ var exc = new Mb_exception(e);
+ }
+};
+
+
+(function () {
+<?php
+ require(dirname(__FILE__)."/../include/dyn_js.php");
+?>
+
+ if (typeof CENTER === "undefined") {
+ var CENTER = [50.7376701, 7.0714];
+ }
- };
+ if (typeof MAX_ZOOM_LEVEL === "undefined") {
+ var MAX_ZOOM_LEVEL = 19;
+ }
+ if (typeof MIN_ZOOM_LEVEL === "undefined") {
+ var MIN_ZOOM_LEVEL = 2;
+ }
- (function () {
+ if (typeof ZOOM_LEVEL === "undefined") {
+ var ZOOM_LEVEL = 10;
+ }
- eventInitMap.register(function () {
- var map = getMapObjByName(mod_google_target);
-
- switch (TYPE) {
- case "ROADMAP" :
- mapTypeId = google.maps.MapTypeId.ROADMAP;
- break;
- case "SATELLITE" :
- mapTypeId = google.maps.MapTypeId.SATELLITE;
- break;
- case "HYBRID" :
- mapTypeId = google.maps.MapTypeId.HYBRID;
- break;
- case "TERRAIN" :
- mapTypeId = google.maps.MapTypeId.TERRAIN;
- break;
- default:
- mapTypeId = google.maps.MapTypeId.SATELLITE;
- break;
- }
+ if (typeof TYPE === "undefined") {
+ var TYPE = "SATELLITE";
+ }
+
+ eventInitMap.register(function () {
+ var map = getMapObjByName(mod_google_target);
+
+ switch (TYPE) {
+ case "ROADMAP" :
+ mapTypeId = google.maps.MapTypeId.ROADMAP;
+ break;
+ case "SATELLITE" :
+ mapTypeId = google.maps.MapTypeId.SATELLITE;
+ break;
+ case "HYBRID" :
+ mapTypeId = google.maps.MapTypeId.HYBRID;
+ break;
+ case "TERRAIN" :
+ mapTypeId = google.maps.MapTypeId.TERRAIN;
+ break;
+ default:
+ mapTypeId = google.maps.MapTypeId.SATELLITE;
+ break;
+ }
- var googleOptions = {
- mapTypeId: mapTypeId,
- key: KEY
- };
-
- map.setGoogleMap(googleOptions);
- });
- })();
-}
\ No newline at end of file
+ var googleOptions = {
+ mapTypeId: mapTypeId,
+ MIN_ZOOM_LEVEL : MIN_ZOOM_LEVEL,
+ MAX_ZOOM_LEVEL : MAX_ZOOM_LEVEL,
+ CENTER : CENTER,
+ ZOOM_LEVEL : ZOOM_LEVEL
+ };
+
+ map.setGoogleMap(googleOptions);
+ });
+})();
More information about the Mapbender_commits
mailing list