รบกวนช่วยหน่ยคะ ไม่ทราบว่ามันผิดอะไร
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา รบกวนช่วยหน่ยคะ ไม่ทราบว่ามันผิดอะไร
รบกวนช่วยหน่ยคะ ไม่ทราบว่ามันผิดอะไร
Copy
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Register Stores</title>
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> -->
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
margin: 0px auto;
width:800px;
height:600px;
}
</style>
</head>
<body>
<div id="map"></div>
<form id="form_get_detailMap" name="form_get_detailMap" method="post" action="">
Latitude : <input name="lat" type="text" id="lat" value="0" size="17" /> <br>
Longitude : <input name="lon_value" type="text" id="long" value="0" size="17" /><br>
Address : <input name="address" id="address" type="text" style="width:380px;height:30px;" size="17"><br>
<input type="submit" name="button" id="button" value="submit" />
</form>
<script>
var myLatLng;
var map;
var marker;
var pos;
var geocoder;
function initMap() {
myLatLng = {lat: 13.745787, lng: 100.392734};
//geocoder = new google.maps.Geocoder();
map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: myLatLng
});
marker = new google.maps.Marker({map: map,
draggable:true, //ทำให้ย้ายmarker
title:"Your Position ",
position:myLatLng
});
map.event.addEventListener(marker,'dragend',function(){
var pos=marker.getPosition();
map.panTo(pos);
$("#lat").val(pos.lat);
$("#long").val(pos.lng);
$("#address").val(results[0].formatted_address);
});
// if (navigator.geolocation) {
// navigator.geolocation.getCurrentPosition(function(position) {
//
// pos = {
// lat: position.coords.latitude,
// lng: position.coords.longitude
// }; //location พิกัดที่เราอยู่
// map.setCenter(pos);
// marker.setPosition(pos); //เอาmarkerไปไว้ในที่อยู่ปัจจุบันของเรา
// $("#lat").val(pos.lat);
// $("#long").val(pos.lng);
// var my_Point = marker.getPosition();
//
// geocoder.geocode({'latLng': my_Point}, function(results, status) {
// if (status == google.maps.GeocoderStatus.OK) {
// if (results[1]) {
// // แสดงข้อมูลสถานที่ใน textarea ที่มี id เท่ากับ address
// $("#address").val(results[1].formatted_address); //
// }
// } else {
// // กรณีไม่มีข้อมูล
// alert("Geocoder failed due to: " + status);
// }
// });
// }, function() {
// handleLocationError(true, marker, map.getCenter());
// });
// } else {
// // Browser doesn't support Geolocation
// handleLocationError(false, marker, map.getCenter());
// }
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDK_U2mdsxXf-l0QWPNv4IGyK6EMKqxBHk&callback=initMap">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
</body>
</html>
มันขึ้นว่า ไม่ทราบว่าันต้องแก้ไขยัง งงมากเลยคะ Uncaught TypeError: Cannot read property 'addEventListener' of undefined Regis.html:50
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ