Skip to content

Instantly share code, notes, and snippets.

@ScorpIan555
Created October 12, 2016 18:10
Show Gist options
  • Select an option

  • Save ScorpIan555/483ef62cc404096d096e4013ef7d2891 to your computer and use it in GitHub Desktop.

Select an option

Save ScorpIan555/483ef62cc404096d096e4013ef7d2891 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 300px;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="img">
<img src="img/Louis_CK.jpg">
</div>
<script>
var map;
var marker;
<!--defines initMap function-->
function initMap() {
<!--declare lattitude/longitude-->
var myLatLng = {lat: -15.363, lng: 13.044};
<!--defines map function-->
map = new google.maps.Map(document.getElementById('map'), {
center: myLatLng,
zoom: 8
});
<!--declares marker-->
var marker = new google.maps.Marker({
map: map,
draggable: true,
animation: google.maps.Animation.DROP,
position: myLatLng,
title: 'My balls itch!'
});
marker.addListener('click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
<!--move this section-->
var myImage = document.querySelector('img');
myImage.onclick = function() {
var mySrc = myImage.getAttribute('src');
if(mySrc === 'images/firefox-icon.png') {
myImage.setAttribute ('src','img/Louis_CK.jpg');
} else {
myImage.setAttribute ('src','img/bojack-header.jpg');
}
}
<!--/move this section-->
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB9ScOkszGKIrzLsIYw0rnaoP-i1-rdlQw&callback=initMap"
async defer></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment