<script src="openlayers.js"></script>    
<script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
    <script type="text/javascript">
  var google = new OpenLayers.Layer.Google(
            "Google Streets", // the default
            {numZoomLevels: 20}

Before adding the Google Maps Layer like this, everything worked. Now I get an TypeError: google.maps is undefined. What is wrong?

Please tell me if I totally misunderstood the concept of adding a google maps layer to openlayers

  • Looks like you are importing google maps api, which you don't need, and not open layers, which you do Oct 22, 2014 at 21:27
  • I DO import open layers as well, and even if I ommit the line <script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>, I still get the same error.
    – Lokomotywa
    Oct 23, 2014 at 8:27
  • Which version of Ol are you using. I mean 2.x.x not 2 or 3. Sometimes the function defs change. Oct 23, 2014 at 12:16
  • I am using OpenLayers 2.14
    – Lokomotywa
    Oct 23, 2014 at 13:11

1 Answer 1


I solved it. The problem is the variable 'google', which overwrites something as it can be imagined.

I call it 'google_layer', now it works - no, it still does not work but at least it does not bring any JS error.

  • ah great, i couldnt work it out either, but now i see its obvious, i was using a variable named google... Sep 7, 2015 at 5:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.