อบรมแผนที่ Google

Google Maps API

บทความนี้เล่าเรื่อง Google Maps API(Application Programming IInterface หรือ ระบบการแก้ตัวโปรแกรม (API)

API คือชุดของวิธีและเครื่องมือที่สามารถใช้เพื่อสร้างโปรแกรมแอปพลิเคชัน

Google Maps ใน HTML

ตัวอย่างนี้สร้างแผนที่ Google Maps ใน HTML:

ตัวอย่าง

<!DOCTYPE html>
<html>
<body>
<h1>我的第一个谷歌地图</h1>
<div id="googleMap" style="width:100%;height:400px;"></div>
<script>
function myMap() {
var mapProp= {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
};
var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY&callback=myMap"></script>
</body>
</html>