Şuanki Dizin: /home/wwwdreamtechnolo/public_html/cakedarbar.in/ |
Şuanki Dosya : /home/wwwdreamtechnolo/public_html/cakedarbar.in/map.html |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Select Delivery Location</title> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCJZ3pJYfmgi5rITkg8B29vbfUOpv5labY&callback=initMap" async defer></script> <style> #map { height: 400px; width: 100%; } .info { margin-top: 20px; } </style> </head> <body> <h2>Select Delivery Location</h2> <div id="map"></div> <div class="info"> <form id="locationForm"> <label>Latitude: <input type="text" id="latitude" name="latitude" readonly></label><br><br> <label>Longitude: <input type="text" id="longitude" name="longitude" readonly></label><br><br> <button type="button" onclick="saveLocation()">Submit</button> </form> <div id="response"></div> </div> <script> let map; let marker; function initMap() { const defaultLocation = { lat: 17.6599, lng: 75.9064 }; // Default location (Solapur, India) map = new google.maps.Map(document.getElementById("map"), { zoom: 13, center: defaultLocation, }); map.addListener("click", (event) => { placeMarker(event.latLng); }); } function placeMarker(location) { if (marker) { marker.setPosition(location); } else { marker = new google.maps.Marker({ position: location, map: map, }); } // Set latitude and longitude in input fields document.getElementById("latitude").value = location.lat(); document.getElementById("longitude").value = location.lng(); } function saveLocation() { const latitude = document.getElementById("latitude").value; const longitude = document.getElementById("longitude").value; if (latitude && longitude) { // Send data to PHP via AJAX const xhr = new XMLHttpRequest(); xhr.open("POST", "save_location.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { document.getElementById("response").innerHTML = xhr.responseText; } }; xhr.send(`latitude=${latitude}&longitude=${longitude}`); } else { alert("Please select a location on the map."); } } </script> </body> </html>
Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4