Skip to content

Instantly share code, notes, and snippets.

@MrKistic
Created July 2, 2013 02:09
Show Gist options
  • Select an option

  • Save MrKistic/5906310 to your computer and use it in GitHub Desktop.

Select an option

Save MrKistic/5906310 to your computer and use it in GitHub Desktop.

Revisions

  1. MrKistic created this gist Jul 2, 2013.
    54 changes: 54 additions & 0 deletions gmap-recentre.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Google Maps JavaScript API v3 Example: Map Simple</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
    <meta charset="utf-8"/>
    <style>

    html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    }

    #map_canvas {
    height: 75%;
    width: 75%;
    margin: 0 auto;
    top: 10%;
    }

    </style>

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>

    <script>

    var map;
    function initialize() {
    var mapOptions = {
    zoom: 15,
    center: new google.maps.LatLng(-37.8212615, 144.9508076),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    };
    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
    }

    google.maps.event.addDomListener(window, 'load', initialize);

    window.onresize = function () {
    lastCenter = map.getCenter();
    google.maps.event.trigger(map_canvas, 'resize');
    map.setCenter(lastCenter);
    };

    </script>

    </head>
    <body>

    <div id="map_canvas"></div>

    </body>
    </html>