I've made a Google map from documentation exmaples. I want to make onclick functions for showing alerts or getting data from clicked objects.
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 90%;
}
html, body {
height: 90%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
let map;
function initMap() {
map = new google.maps.Map ( document.getElementById( 'map' ), {
center: {
lat: 51.513329,
lng: -0.088950
},
zoom: 14
});
}
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addListener(map, 'click', function(event) {alert('Hi');});
</script>
<script src=" https://maps.googleapis.com/maps/api/js?key=key&callback=initMap" async defer></script>
</body>
</html>
But on Edge I get "google is not defined".
I've tried many times, putting scripts on top, adding code, no work. Simply call any function onclick - but examples are not working, even simple ones.
I want to have any function launch onclick (adding objects, alert, current data etc), but the error is unclear. My key is active.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/jy5cm7K
Comments
Post a Comment