UK Google Map With A Draggable Marker

Created Using OpenLayers API , Google Maps API

You may prefer to load Google maps directly using Google's API, see the Google Version for a working example.

Since it is part of Google's T&C for using their tiles that only Google code can be used to retrieve them, OL has to load all of Google's mapping code anyway, resulting in two sets of mapping code being loaded to produce the one map, and unsurprisingly the result tends to be clunky, particularly on slow machines.  However, a reason to use OL may be that you get a wider variety of controls, and greater control over their positioning.

Note also the following:

Significant updates to this document
Date Description
16/02/2017 Seemingly another arbitrary change by Google, now the map won't display unless the initial zoom is <= 17.
01/10/2017 Slight change to allow for https protocol.
12/01/2017 So many changes at Google and OpenLayers over the years that decided rather belatedly that an update record is required.  Obtained new Google API key, as legacy authentication now not recognised.  Improved control of asynchronous code loading.  Made satellite initial baselayer, as this seems to be necessary to get the map to display.
21/11/2021 Another random bug from either Google or OL, now the map won't display unless the initial zoom is <= 11, so we must load at that zoom and then change it to something more useful after a timed delay.
26/02/2022 Reconciled coding with other OpenLayers v2 demos, so that all are as alike as possible.