Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaelachrisco/9cdb11d555c60c4d85b2054b3a353f4b to your computer and use it in GitHub Desktop.
Save michaelachrisco/9cdb11d555c60c4d85b2054b3a353f4b to your computer and use it in GitHub Desktop.
Google Maps API v3 - Basic Map
<div id="map-canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false" type="text/javascript"></script>
// if HTML DOM Element that contains the map is found...
if (document.getElementById('map-canvas')){
// Coordinates to center the map
var myLatlng = new google.maps.LatLng(52.525595,13.393085);
// Other options for the map, pretty much selfexplanatory
var mapOptions = {
zoom: 14,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Attach a map to the DOM Element, with the defined settings
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
#map-canvas{
height: 500px;
width: 500px;
border: 3px solid black;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment