[Mapbender_dev] google maps api, openlayers and mapbender

Hernan Olivera lholivera at gmail.com
Thu Jan 27 16:51:56 EST 2011

Hi all

I think this is the right list to ask this question, not users. Sorry
if I'm wrong.

I'm trying to modify Openlayers code to include Google Maps layers.
I'm using the openlayers google example as a template for what I need
(google-v3.html in openlayes examples), that works ok. I want to
include this functionality in openlayers included in mapbender (maybe
it became a wrapper for this later)

I've added this line in the head section of index.php:
<script src="http://maps.google.com/maps/api/js?v=3.2&amp;sensor=false"></script>

and this lines in ol.js, that sets the layers, from the OpenLayers example:

    map.addControl(new OpenLayers.Control.LayerSwitcher());

    var gsat = new OpenLayers.Layer.Google(
        "Google Satellite",
        {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22,
visibility: true}

    // Google.v3 uses EPSG:900913 as projection, so we have to
    // transform our coordinates
    map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform(
        new OpenLayers.Projection("EPSG:4326"),
    ), 5);

This should generate the code needed to setup google layers in mapbender.

The line in he head section generates this error:
Javascript not found: http://maps.google.com/maps/api/js?sensor=false
I've solved this changing the line:
<script src="http://maps.google.com/maps/api/js?v=3.2&amp;sensor=false"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>

because v3 is now the default version, and '&amp;' causes error on
sensor parameter.
Now this works (most the time), but  I don't know why the original
line doesn't work.

But now I have an error in map.php, reported by firebug:
this.termsOfUse is null

in map.php line 4391:

I love to know what do you think about this. Maybe there is a better
way to do this.
But now it become difficult to see what is happening with this error.

I think it is a good feature if we can use google maps on openlayers
on mapbender.

Any help is appreciated


Hernan Olivera

More information about the Mapbender_dev mailing list