Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,025

HOME > Google Maps APIs สอนวิธีการใช้ Maps ของ Google เพื่อเรียกใช้งานแผนที่และแสดงผลบนเว็บไซต์ > ตอนที่ 3 : Google Maps API การแสดงมุมมองของแผนที่ต่างๆ เช่น Zoom , Map Type



Clound SSD Virtual Server

ตอนที่ 3 : Google Maps API การแสดงมุมมองของแผนที่ต่างๆ เช่น Zoom , Map Type

Google Maps API การแสดงมุมมองของแผนที่ต่างๆ เช่น Zoom , Map Type การแสดงผลแผนที่จาก Google Map เราสามารถกำหนดและขนาดของแผนที่ด้วยการ Zoom ย่อขยายแผนที่ให้ได้ตามมาตรส่วนที่ต้องการแสดงผล โดยสามารถ Zoom ได้ในระดับ 0-21 และยังสามาารถกำหนดชนิดและขนาดของ Map Type ที่จะแสดงผลได้ด้วย ซึ่งจะมีอยู่ประมาณ 4 ชนิดด้วยกัน ROADMAP, SATELLITE , HYBRID และ TERRAIN แต่ล่ะประเภทก็ขึ้นอยู่กับว่า ต้องการแสดงแผนที่ในมุมมองรูปแบบใด




Google Map API and Map Type


รูปแบบของ Map Type ที่สามารถเรียกใช้งานได้บน Google Map API
  • ROADMAP (แสดงถนนปกติ, เป็นค่า Default แบบ 2D หรือ 2 มิติ)
  • SATELLITE (ภาพจากดาวเทียม)
  • HYBRID (แบบปกติผสมกับดาวเทียม)
  • TERRAIN (แบบภาพภูมิศาสตร์)


การ Zoom สามารถกำหนดค่าจาก 0 - 21
<script> var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: 13.847860, lng: 100.604274}, zoom: 0-21 }); } </script>


การ เปลี่ยน Map Type
<script> var map; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: 13.847860, lng: 100.604274}, zoom: 18, mapTypeId:google.maps.MapTypeId.[ROADMAP/SATELLITE/HYBRID/TERRAIN] }); } </script>



Ex 1 : การ Zoom ในระดับ 0

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 0
        });
      }
    </script>

Google Map API Map Type








Ex 2 : การ Zoom ในระดับ 10

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 10
        });
      }
    </script>

Google Map API Map Type



Ex 3 : การ Zoom ในระดับ 21

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 21
        });
      }
    </script>

Google Map API Map Type



Ex 4 : การกำหนด Map Type แบบ ROADMAP (แสดงถนนปกติ, เป็นค่า Default แบบ 2D หรือ 2 มิติ)

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 18,
          mapTypeId:google.maps.MapTypeId.ROADMAP
        });
      }
    </script>

Google Map API Map Type



Ex 5 : การกำหนด Map Type แบบ SATELLITE (ภาพจากดาวเทียม)

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 18,
          mapTypeId:google.maps.MapTypeId.SATELLITE
        });
      }
    </script>

Google Map API Map Type



Ex 6 : การกำหนด Map Type แบบ HYBRID (แบบปกติผสมกับดาวเทียม)

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 18,
          mapTypeId:google.maps.MapTypeId.HYBRID
        });
      }
    </script>

Google Map API Map Type



Ex 7 : การกำหนด Map Type แบบ TERRAIN (แบบภาพภูมิศาสตร์)

    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 18,
          mapTypeId:google.maps.MapTypeId.TERRAIN
        });
      }
    </script>

Google Map API Map Type

ทั้งนี้การกำหนดค่า Zoom หรือ Map Type ก็ขึ้นอยุ่กับว่าต้องการแสดงภาพในมุมมองไหน








Code ของหน้านี้
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html {
        height: 100%;
        margin: 0;
        padding: 0;
		text-align: center;
      }

      #map {
        height: 500px;
        width: 600px;
      }
    </style>
  </head>
  <body>
  <div id="map"></div>
    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 13.847860, lng: 100.604274},
          zoom: 18,
		  mapTypeId:google.maps.MapTypeId.TERRAIN
        });
      }
    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAK3RgqSLy1toc4lkh2JVFQ5ipuRB106vU&callback=initMap" async defer></script>
  </body>
</html>


   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2017-04-08 21:58:21 / 2017-04-09 06:50:01
  Download : No files
 Sponsored Links / Related

 
ตอนที่ 1 : Google Maps API (JavaScript) เบื้องต้นกับการใช้งานแผนที่บนของกูเกิลแมพ (Step by Step)
Rating :

 
ตอนที่ 2 : Google Maps API การเปิด-ปิด Control ต่างๆ ที่อยู่บนหน้า Maps แผนที่
Rating :

 
ตอนที่ 4 : Google Maps API การสร้าง Custom Maps Style กำหนดรูปแบบของแผนที่
Rating :

 
ตอนที่ 5 : Google Maps API การปักหมุด (Marker) บนแผนที่ จาก Lat,Lon และรายละเอียด
Rating :

 
ตอนที่ 6 : Google Maps API การปักหมุด (Marker) หลายตำแหน่งจากข้อมูลชุด Array
Rating :

 
ตอนที่ 7 : Google Maps API การปักหมุด (Marker) หลายตำแหน่งจากข้อมูลชุด Json Object
Rating :

 
ตอนที่ 8 : Google Maps API Geolocation การอ่านและโฟกัสตำแหน่ง Location ปัจจุบัน
Rating :

 
ตอนที่ 9 : Google Maps API Geocoding การค้นหาระบุตำแหน่ง Location บนแผนที่
Rating :

 
ตอนที่ 10 : Google Maps API การปักหมุด (Marker) บนแผนที่ จาก PHP/MySQL (Json)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่