Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display a Google Map using the Maps JavaScript API
<style>
#map_canvas {
height: 400px;
width: 600px;
border: 1px solid black;
}
</style>
<div id="map_canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_GOES_HERE&sensor=false"></script>
<script>
function initialize() {
var myLocation = {
'latitude': 48.858574,
'longitude': 2.294508,
'address': 'Eiffel Tower, Paris'
};
var myLatlng = new google.maps.LatLng( myLocation.latitude, myLocation.longitude );
var mapOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: myLocation.address
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.