A simple example of a marker on a Google map.
Last active
June 12, 2016 09:42
-
-
Save jeffreymorganio/f2edec157adbc31a2e47a956831ba6e5 to your computer and use it in GitHub Desktop.
A marker on a Google map.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<link rel="stylesheet" href="map.css"> | |
<script src="https://maps.google.com/maps/api/js"></script> | |
<script src="map.js"></script> | |
<title>Google Map Marker</title> | |
</head> | |
<body onload="showMap()"> | |
<div id="google-map"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#google-map { | |
width: 962px; | |
height: 502px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var map = null; | |
var zoomLevel = 12; | |
var eiffelTower = new google.maps.LatLng(48.858093, 2.294694); | |
function showMap() { | |
initMap(); | |
addMarker(); | |
} | |
function initMap() { | |
var mapOptions = { | |
center: eiffelTower, | |
zoom: zoomLevel, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var mapElement = document.getElementById('google-map'); | |
map = new google.maps.Map(mapElement, mapOptions); | |
} | |
function addMarker() { | |
new google.maps.Marker({ | |
map: this.map, | |
position: this.eiffelTower | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment