Map panBy example

by Lawrence Ross

HTML

<!doctype html>
<html>
  <head>
    <title>Complex Marker Icons</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
    <!-- jsFiddle will insert css and js -->
  </head>
  <body>
    <div id="map_canvas"></div>

    <!-- 
      The `defer` attribute causes the callback to execute after the full HTML
      document has been parsed. For non-blocking uses, avoiding race conditions,
      and consistent behavior across browsers, consider loading using Promises.
      See https://developers.google.com/maps/documentation/javascript/load-maps-js-api
      for more information.
      -->
    <script
      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initialize&v=weekly"
      defer
    ></script>
  </body>
</html>

CSS

/* 
 * Always set the map height explicitly to define the size of the div element
 * that contains the map. 
 */
#map_canvas {
  height: 100%;
}

/* 
 * Optional: Makes the sample page fill the window. 
 */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

JavaScript

function initialize() {

var PlainStyle = [

{featureType: "administrative",elementType: "all",stylers: [{ visibility: "on" }]},
{featureType: "landscape",elementType: "all",stylers: [{ visibility: "on" }]},
{featureType: "poi",elementType: "all",stylers: [{ visibility: "on" }]},
{featureType: "road",elementType: "all",stylers: [{ visibility: "on" }]},
{featureType: "transit",elementType: "all",stylers: [{ visibility: "on" }]},
{featureType: "water",elementType: "all",stylers: [{ visibility: "on" }]},
];

var latlng = new google.maps.LatLng(-33.9, 151.2);
var myOptions = { 
zoom: 19,
center: latlng, 
panControl: false,
zoomControl: false,
scaleControl: false,
fullscreenControl: true,
streetViewControl: false,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.SATELLITE,
};

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  map.setOptions({
    styles: PlainStyle
  });
  google.maps.event.addListenerOnce(map, 'tilesloaded', function() {
    map.panBy(100, 500)
  })

}

window.initialize = initialize;