Created
February 26, 2021 05:18
-
-
Save hhkaos/20ed931e49234286113fe8da2745f416 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<style>#mapDiv{width:100%; height:400px}</style> | |
</head> | |
<body> | |
<h1>Drawing marker in Google Maps</h1> | |
<div id="mapDiv"></div> | |
<script> | |
function initMap() { | |
const map = new google.maps.Map(document.getElementById('mapDiv'), { | |
mapTypeId: 'roadmap', | |
center: { | |
lat: 32.7353, | |
lng: -117.1490 | |
}, | |
zoom: 12 | |
}); | |
const marker = new google.maps.Marker({ | |
position: { | |
lat: 32.7353, | |
lng: -117.1490 | |
}, | |
title: "San Diego Zoo", | |
map: map | |
}); | |
const infowindow = new google.maps.InfoWindow({ | |
content: "<h1>San Diego Zoo</h1>" + | |
"The <a href='http://zoo.sandiegozoo.org/'>San Diego Zoo</a> " + | |
" in Balboa Park houses over 3,700 animals.<p><p>" + | |
"<img src='https://visitoceanside.org/wp-content/uploads/2013/01/SanDiegoZoo.jpg' alt='San Diego Zoo' height='150'>" | |
}); | |
marker.addListener('click', function() { | |
infowindow.open(map, marker); | |
}); | |
} | |
</script> | |
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment