โดย Ik Kat » 03/07/2017 3:45 pm
การปรับเปลี่ยนมุมมอง Map Type สามารถทำได้โดยใช้
Google Maps JavaScript API ซึ่งมีให้เลือกใช้ได้ทั้งหมด 4 รูปแบบ ซึ่งแต่ล่ะรูปแบบมีมุมมองที่ต่างกัน ดังนี้
รูปแบบของ Map Type ที่อยู่บน Google Maps :
- roadmap displays มุมมองปกติ เป็นค่าเริ่มต้นที่สามารถมองได้ในรูปแบบ 2 มิติ
- satellite displays การแสดงภาพจากดาวเทียม
- hybrid displays เป็นการผสมระหว่างมุมมองปกติ และภาพจากดาวเทียม
- terrain displays เป็นแผนที่ทางภูมิศาสตร์
ตัวอย่าง ROADMAP :
โค้ด: เลือกทั้งหมด
var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'roadmap'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);
ตัวอย่าง SATELLITE :
โค้ด: เลือกทั้งหมด
var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'satellite'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);
ตัวอย่าง HYBRID :
โค้ด: เลือกทั้งหมด
var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'hybrid'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);
ตัวอย่าง TERRAIN :
โค้ด: เลือกทั้งหมด
var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'terrain'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);
โค้ด: เลือกทั้งหมด
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 13.8380209, lng: 100.5814654},
zoom: 18,
mapTypeId: 'satellite'
});
map.setTilt(45);
}
- หากต้องการปิดให้ตั้งเป็น map.setTilt(0);
- หากต้องการเปิดให้ตั้งเป็น map.setTilt(45);
- MT19 3-7-60(15).png (860.88 KiB) Viewed 2789 times
โค้ด: เลือกทั้งหมด
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 13.8380209, lng: 100.5814654},
zoom: 15,
mapTypeId: 'satellite',
heading: 90,
tilt: 45
});
}
function rotate90() {
var heading = map.getHeading() || 0;
map.setHeading(heading + 90);
}
function autoRotate() {
// Determine if we're showing aerial imagery.
if (map.getTilt() !== 0) {
window.setInterval(rotate90, 3000);
}
}
การปรับเปลี่ยนมุมมอง Map Type สามารถทำได้โดยใช้ [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1/33-google/3780-google-map-%E0%B8%81%E0%B8%B9%E0%B9%80%E0%B8%81%E0%B8%B4%E0%B8%A5.htmlhttp://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1/33-google/3780-google-map-%E0%B8%81%E0%B8%B9%E0%B9%80%E0%B8%81%E0%B8%B4%E0%B8%A5.html]Google Maps[/url] [url=https://www.mindphp.com/%E0%B8%84%E0%B8%B9%E0%B9%88%E0%B8%A1%E0%B8%B7%E0%B8%AD/73-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/2187-java-javascript-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3.html]JavaScript[/url] [url=https://www.mindphp.com/%E0%B8%84%E0%B8%B9%E0%B9%88%E0%B8%A1%E0%B8%B7%E0%B8%AD/73-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/2038-api-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3.html]API[/url] ซึ่งมีให้เลือกใช้ได้ทั้งหมด 4 รูปแบบ ซึ่งแต่ล่ะรูปแบบมีมุมมองที่ต่างกัน ดังนี้
[b]รูปแบบของ Map Type ที่อยู่บน Google Maps :[/b]
- roadmap displays มุมมองปกติ เป็นค่าเริ่มต้นที่สามารถมองได้ในรูปแบบ 2 มิติ
- satellite displays การแสดงภาพจากดาวเทียม
- hybrid displays เป็นการผสมระหว่างมุมมองปกติ และภาพจากดาวเทียม
- terrain displays เป็นแผนที่ทางภูมิศาสตร์
[b]ตัวอย่าง ROADMAP : [/b]
[code]var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'roadmap'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);[/code]
[img]http://snap.mindphp.com/index.php?view=2017Jul03_5959fd40f1346[/img]
[b]ตัวอย่าง SATELLITE :[/b]
[code]var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'satellite'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);[/code]
[img]http://snap.mindphp.com/index.php?view=2017Jul03_5959fe53016db[/img]
[b]ตัวอย่าง HYBRID : [/b]
[code]var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'hybrid'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);[/code]
[img]http://snap.mindphp.com/index.php?view=2017Jul03_5959febaa8f87[/img]
[b]ตัวอย่าง TERRAIN : [/b]
[code]var myLatlng = new google.maps.LatLng(13.8380209, 100.5814654);
var mapOptions = {
zoom: 15,
center: myLatlng,
mapTypeId: 'terrain'
};
var map = new google.maps.Map(document.getElementById('map'),
mapOptions);[/code]
[img]http://snap.mindphp.com/index.php?view=2017Jul03_5959fed6b42f6[/img]
[code]การเปิดใช้งานและปิดใช้งานภาพ 45 องศา :[/code]
[code]function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 13.8380209, lng: 100.5814654},
zoom: 18,
mapTypeId: 'satellite'
});
map.setTilt(45);
}[/code]
[list]หากต้องการปิดให้ตั้งเป็น map.setTilt(0); [/list]
[list]หากต้องการเปิดให้ตั้งเป็น map.setTilt(45); [/list]
[attachment=0]MT19 3-7-60(15).png[/attachment]
[code]การหมุนภาพ 45 องศา :[/code]
[code]var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 13.8380209, lng: 100.5814654},
zoom: 15,
mapTypeId: 'satellite',
heading: 90,
tilt: 45
});
}
function rotate90() {
var heading = map.getHeading() || 0;
map.setHeading(heading + 90);
}
function autoRotate() {
// Determine if we're showing aerial imagery.
if (map.getTilt() !== 0) {
window.setInterval(rotate90, 3000);
}
}[/code]