This is my script at the top of my HTML file

<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false">
<script type="text/JavaScript" src="map.js"></script>

This is my .js

var map;
function initMap() {
//initialise variables
 var osmlayer;
 var trackloca2;
 var bmenatrack2;
 var pits3;
 var boundary3;
 var track2;
 var pits2;
 var boundaryline;
 var gmap;
//create new map object
map = new OpenLayers.Map("mymap");
 //create new OSM base layer
 osmlayer = new OpenLayers.Layer.OSM("Open Street Map");
 gmap = new OpenLayers.Layer.Google(
    "Google Streets",
    {numZoomLevels: 20}

I have added gmap to the addlayers at the bottom but when I switch from the open street map to the google layer all I am getting is a white screen with my geoserver layers showing,

  • Wow, thanks for tidying this all up, I was just in a panic yesterday to try and get it up so it might get answered. Am I missing something simple as to why it wont show the Google base layer also? – David Laverty May 9 '17 at 16:00
  • Just an aside, the latest version of OpenLayers is v4.2.0. If you don't already have a large codebase, you might consider switching versions. – Brynne Jun 30 '17 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.