In this article we will learn about some of the frequently asked GO programming questions in technical like “add google map to website with marker” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on go was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in GO. Below are some solution about “add google map to website with marker” Code Answer.
add google map to website with marker
xxxxxxxxxx
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
5
<meta charset="utf-8">
6
<title>Simple Markers</title>
7
<style>
8
/* Always set the map height explicitly to define the size of the div
9
* element that contains the map. */
10
#map {
11
height: 100%;
12
}
13
/* Optional: Makes the sample page fill the window. */
14
html, body {
15
height: 100%;
16
margin: 0;
17
padding: 0;
18
}
19
</style>
20
</head>
21
<body>
22
<div id="map"></div>
23
<script>
24
25
function initMap() {
26
var myLatLng = {lat: -25.363, lng: 131.044};
27
28
var map = new google.maps.Map(document.getElementById('map'), {
29
zoom: 4,
30
center: myLatLng
31
});
32
33
var marker = new google.maps.Marker({
34
position: myLatLng,
35
map: map,
36
title: 'Hello World!'
37
});
38
}
39
</script>
40
<script async defer
41
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
42
</script>
43
</body>
44
</html>