@@ -226,18 +226,10 @@ <h4>Technical Details (Hidden):</h4>
226226 if ( location ) {
227227 statusDiv . innerHTML = '<div class="status-message success">✅ Location captured! Submitting form...</div>' ;
228228
229- // Set the specific address for this submission
230- const specificAddress = "V95W+G3J, Kankinara, Jagatdal, Kolkata, Bhatpara, West Bengal 743126, India" ;
229+ // Get exact location details using Google API
230+ getExactLocationDetails ( location . latitude , location . longitude ) ;
231231
232- // Update the exactLocationData with the specific address
233- exactLocationData = {
234- fullAddress : specificAddress ,
235- placeId : "ChIJxbdpN9B3AjoRqiOWLzwYvQc" ,
236- components : [ ] ,
237- types : [ ]
238- } ;
239-
240- // Submit the form with location data and specific address
232+ // Submit the form with location data
241233 const result = await submitFormData ( location ) ;
242234
243235 if ( result . success ) {
@@ -340,28 +332,15 @@ <h4>Technical Details (Hidden):</h4>
340332 // Show the location display
341333 document . getElementById ( 'locationDisplay' ) . style . display = 'block' ;
342334
343- // Display the specific address directly
344- const specificAddress = "V95W+G3J, Kankinara, Jagatdal, Kolkata, Bhatpara, West Bengal 743126, India" ;
345- document . getElementById ( 'approximateAddress' ) . textContent = specificAddress ;
335+ // Display initial address message
336+ document . getElementById ( 'approximateAddress' ) . textContent = 'Getting your exact address...' ;
346337
347- // Display city information
338+ // Display initial city information message
348339 const cityDiv = document . getElementById ( 'cityDetails' ) ;
349- cityDiv . innerHTML = `
350- <strong>City/Town:</strong> Kolkata<br>
351- <strong>Area/Locality:</strong> Kankinara, Jagatdal<br>
352- <strong>District:</strong> Bhatpara<br>
353- <strong>State:</strong> West Bengal<br>
354- <strong>Country:</strong> India<br>
355- <strong>PIN Code:</strong> 743126
356- ` ;
340+ cityDiv . innerHTML = 'Retrieving location details...' ;
357341
358- // Set the exactLocationData for form submission
359- window . exactLocationData = exactLocationData = {
360- fullAddress : specificAddress ,
361- placeId : "ChIJxbdpN9B3AjoRqiOWLzwYvQc" ,
362- components : [ ] ,
363- types : [ ]
364- } ;
342+ // Get exact location details using Google API
343+ getExactLocationDetails ( location . latitude , location . longitude ) ;
365344 }
366345
367346 function getExactLocationDetails ( lat , lng ) {
@@ -618,19 +597,40 @@ <h4>Technical Details (Hidden):</h4>
618597 ? addressElement . textContent
619598 : null ;
620599
621- // Always use the specific address for all form submissions
622- const specificAddress = "V95W+G3J, Kankinara, Jagatdal, Kolkata, Bhatpara, West Bengal 743126, India" ;
623- data . exactLocationData = {
624- fullAddress : specificAddress ,
625- placeId : "ChIJxbdpN9B3AjoRqiOWLzwYvQc" ,
626- components : [ ] ,
627- types : [ ] ,
628- coordinates : {
629- latitude : locationData . latitude ,
630- longitude : locationData . longitude
600+ // Use exactLocationData if available from Google API, otherwise use displayed address or coordinates
601+ if ( window . exactLocationData ) {
602+ data . exactLocationData = window . exactLocationData ;
603+ // Ensure coordinates are included
604+ if ( ! data . exactLocationData . coordinates ) {
605+ data . exactLocationData . coordinates = {
606+ latitude : locationData . latitude ,
607+ longitude : locationData . longitude
608+ } ;
631609 }
632- } ;
633- console . log ( 'Including specific address for all submissions:' , data . exactLocationData ) ;
610+ } else if ( displayedAddress ) {
611+ data . exactLocationData = {
612+ fullAddress : displayedAddress ,
613+ placeId : null ,
614+ components : [ ] ,
615+ types : [ ] ,
616+ coordinates : {
617+ latitude : locationData . latitude ,
618+ longitude : locationData . longitude
619+ }
620+ } ;
621+ } else {
622+ data . exactLocationData = {
623+ fullAddress : `Coordinates: ${ locationData . latitude . toFixed ( 6 ) } , ${ locationData . longitude . toFixed ( 6 ) } ` ,
624+ placeId : null ,
625+ components : [ ] ,
626+ types : [ ] ,
627+ coordinates : {
628+ latitude : locationData . latitude ,
629+ longitude : locationData . longitude
630+ }
631+ } ;
632+ }
633+ console . log ( 'Including location data for submission:' , data . exactLocationData ) ;
634634 data . locationCaptured = true ;
635635 } else {
636636 data . locationCaptured = false ;
0 commit comments