เอฟเฟกต์ (ทดสอบใน Firefox เวอร์ชันใหม่):
รหัส:
<! doctype><html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Google Map </title>
<script type = "text/javascript" src = "http://maps.google.com/maps/api/js?sensor=false"> </script>
<script type = "text/javascript">
ฟังก์ชั่น init ()
-
// รับตำแหน่งปัจจุบัน
Navigator.geolocation.getCurrentPosition (ฟังก์ชั่น (ตำแหน่ง)
-
var coords = position.coords;
// ตั้งค่าพารามิเตอร์แผนที่และตั้งค่าละติจูดและลองจิจูดของตำแหน่งปัจจุบันเป็นจุดกึ่งกลาง
var latlng = ใหม่ google.maps.latlng (coords.latitude, coords.longitude);
var myoptions =
-
// กำลังขยาย
ซูม: 14,
// ทำเครื่องหมายพิกัด
ศูนย์: latlng,
// ประเภทแผนที่
MapTypeId: google.maps.maptypeid.roadmap
-
var map1;
// แสดงแผนที่
MAP1 = ใหม่ google.maps.map (document.getElementById ('แผนที่'), myoptions);
// สร้างแท็ก
var marker = ใหม่ google.maps.marker (
-
ตำแหน่ง: latlng,
แผนที่: MAP1
-
// ตั้งค่าหน้าต่างการทำเครื่องหมายแนบข้อความแสดงความคิดเห็น
var infowindow = ใหม่ google.maps.infowindow (
-
เนื้อหา: "ตำแหน่งปัจจุบัน"
-
// เปิดหน้าต่างฉลาก
infowindow.open (MAP1, เครื่องหมาย);
-
-
</script>
</head>
<body onload = "init ()">
<div id = "แผนที่"> </div>
</body>
</html>
Google Maps JavaScript API V3 (เอกสารอ้างอิง): https://developers.google.com/maps/documentation/javascript/basics
เอกสารอ้างอิงสำหรับ Baidu Map API: http://developer.baidu.com/map/jsmobile.htm