|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<body> |
| 4 | + |
| 5 | +<h1>My First Google Map</h1> |
| 6 | + |
| 7 | +<div id="map" style="width:100%;height:400px;"></div> |
| 8 | + |
| 9 | +<script> |
| 10 | +function myMap() { |
| 11 | +var mapProp= { |
| 12 | + center:new google.maps.LatLng(51.508742,-0.120850), |
| 13 | + zoom:5, |
| 14 | +}; |
| 15 | +var map = new google.maps.Map(document.getElementById("googleMap"),mapProp); |
| 16 | +} |
| 17 | + |
| 18 | +// This example creates a 2-pixel-wide red polyline showing the path of |
| 19 | +// the first trans-Pacific flight between Oakland, CA, and Brisbane, |
| 20 | +// Australia which was made by Charles Kingsford Smith. |
| 21 | +function initMap() { |
| 22 | + const map = new google.maps.Map(document.getElementById("map"), { |
| 23 | + zoom: 3, |
| 24 | + center: { lat: 0, lng: -180 }, |
| 25 | + mapTypeId: "terrain", |
| 26 | + }); |
| 27 | + const flightPlanCoordinates = [ |
| 28 | + { lat: 37.772, lng: -122.214 }, |
| 29 | + { lat: 21.291, lng: -157.821 }, |
| 30 | + { lat: -18.142, lng: 178.431 }, |
| 31 | + { lat: -27.467, lng: 153.027 }, |
| 32 | + ]; |
| 33 | + const flightPath = new google.maps.Polyline({ |
| 34 | + path: flightPlanCoordinates, |
| 35 | + geodesic: true, |
| 36 | + strokeColor: "#FF0000", |
| 37 | + strokeOpacity: 1.0, |
| 38 | + strokeWeight: 2, |
| 39 | + }); |
| 40 | + |
| 41 | + flightPath.setMap(map); |
| 42 | +} |
| 43 | + |
| 44 | +window.initMap = initMap; |
| 45 | +</script> |
| 46 | + |
| 47 | +<script |
| 48 | + src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDn3qiuLXithyg0abP8MChBwXwvInbyFYk&callback=initMap" |
| 49 | + defer |
| 50 | +></script> |
| 51 | + |
| 52 | +</body> |
| 53 | +</html> |
0 commit comments