Running jQuery Geolocation scripts in Excel spreadsheets

Can I use my jquery script in an Excel spreadsheet? I am trying to use geolocation to be able to automatically populate an address. I can do it via html. http://jsfiddle.net/bobrierton/13ffw6ko/ But I wonder how I can achieve the same goal on an excel sheet.

I want the columns in the spreadsheet to be Address, City, State, Zipcode, and then every time the address is clicked, I want it to populate and give recommendations like my version of html here.

Someone please help as possible.

var placeSearch, autocomplete; var componentForm = { route: 'long_name', locality: 'long_name', administrative_area_level_1: 'short_name', postal_code: 'short_name' }; function initialize() { // Create the autocomplete object, restricting the search // to geographical location types. autocomplete = new google.maps.places.Autocomplete( /** @type {HTMLInputElement} */ (document.getElementById('autocomplete')), { types: ['geocode'] }); // When the user selects an address from the dropdown, // populate the address fields in the form. google.maps.event.addListener(autocomplete, 'place_changed', function() { fillInAddress(); }); } // [START region_fillform] function fillInAddress() { // Get the place details from the autocomplete object. var place = autocomplete.getPlace(); for (var component in componentForm) { document.getElementById(component).value = ''; document.getElementById(component).disabled = false; } // Get each component of the address from the place details // and fill the corresponding field on the form. for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; document.getElementById(addressType).value = val; } } //var keys=[];for (var key in place.address_components[0]) keys.push(key); //alert(keys): document.getElementById('autocomplete').value = place.address_components[0]['long_name'] + ' ' + place.address_components[1]['long_name']; /*document.getElementById('route').value = (document.getElementById('chbSame').checked ? document.getElementById('autocomplete').value : '');*/ document.getElementById('route').value = ''; } // [START region_geolocation] // Bias the autocomplete object to the user geographical location, // as supplied by the browser 'navigator.geolocation' object. function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geolocation = new google.maps.LatLng( position.coords.latitude, position.coords.longitude); var circle = new google.maps.Circle({ center: geolocation, radius: position.coords.accuracy }); autocomplete.setBounds(circle.getBounds()); }); } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script> <body onload="initialize()"> <div id="locationField"> <div class="clearfix"> <label for="street_<cfoutput>#Add#</cfoutput>">Mailing Address 1:</label> <input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount# mailing address." onFocus="geolocate()" value=""> </div> <div class="clearfix"> <label for="m2street_<cfoutput>#Add#</cfoutput>">Mailing Address 2:</label> <input type="text" name="m2street_#Add#" validateat="onSubmit" required="no" validate="maxlength" id="route" size="54" maxlength="120" value=""> </div> <div class="clearfix"> <label for="city_<cfoutput>#Add#</cfoutput>">City:</label> <input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount# mailing city." value=""> </div> <div class="clearfix"> <label for="state_<cfoutput>#Add#</cfoutput>">State:</label> <input type="text" name="state_#Add#" required="yes" id="administrative_area_level_1" size="8" maxlength="12" message="Please enter owner #Peoplecount# mailing state." value=""> </div> <div class="clearfix"> <label for="street_<cfoutput>#Add#</cfoutput>">Zip Code:</label> <input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount# mailing zip code." value=""> </div> </div> 
+5
source share
1 answer

Can I use my jquery script in an Excel spreadsheet? I am trying to use geolocation to be able to automatically populate an address.

No. Your script relies on the Google Maps API and requires the browser context to work correctly.

As long as you can run JavaScript in a Windows script host, you need much more than JavaScript. You need a browser API, complete with a geolocation API and AJAX. You will not find this in Excel.

However, you can get creative. You can create HTTP requests with your script (albeit not in the usual AJAX way). Perhaps you can also run an external application to get a position for you.

0
source

Source: https://habr.com/ru/post/1236336/


All Articles