2015-11-19 8 views
5

क्या एक्सेल स्प्रैडशीट में मेरी jquery स्क्रिप्ट का उपयोग करना संभव है? मैं भौगोलिक स्थान का उपयोग करने के लिए एक स्वचालित पता भरने की सुविधा रखने की कोशिश कर रहा हूं। मैं इसे HTML के माध्यम से करने में सक्षम हूं। http://jsfiddle.net/bobrierton/13ffw6ko/ लेकिन मैं उत्सुक हूं कि मैं एक्सेल शीट में एक ही लक्ष्य कैसे प्राप्त कर सकता हूं।एक्सेल स्प्रेडशीट्स में JQuery जिओलोकेशन स्क्रिप्ट चलाएं

मैं स्प्रेडशीट में कॉलम पता, शहर, राज्य, ज़िपकोड होना चाहता हूं और फिर हर बार जब कोई पता क्लिक किया जाता है, तो मैं इसे अपने एचटीएमएल संस्करण की तरह प्रीफिल करना और सिफारिश देना चाहता हूं।

क्या कोई इस बात की सहायता करेगा कि यह कैसे संभव हो सकता है।

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's geographical location, 
 
// as supplied by the browser's '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"> 
 
    \t <label for="street_<cfoutput>#Add#</cfoutput>">Mailing Address 1:</label> 
 
    \t <input type="text" name="street_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="autocomplete" size="54" maxlength="120" message="Please enter owner #Peoplecount#'s mailing address." onFocus="geolocate()" value=""> 
 
    </div> 
 

 
    <div class="clearfix"> 
 
    \t <label for="m2street_<cfoutput>#Add#</cfoutput>">Mailing Address 2:</label> 
 
    \t <input type="text" name="m2street_#Add#" validateat="onSubmit" required="no" validate="maxlength" id="route" size="54" maxlength="120" value=""> 
 
    </div> 
 
     
 
    <div class="clearfix"> 
 
    \t <label for="city_<cfoutput>#Add#</cfoutput>">City:</label> 
 
    \t <input type="text" name="city_#Add#" validateat="onSubmit" validate="maxlength" required="yes" id="locality" size="30" maxlength="50" message="Please enter owner #Peoplecount#'s mailing city." value=""> 
 
     </div> 
 
     
 
     <div class="clearfix"> 
 
    \t <label for="state_<cfoutput>#Add#</cfoutput>">State:</label> 
 
    \t <input type="text" name="state_#Add#" required="yes" id="administrative_area_level_1" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing state." value=""> 
 
    </div> 
 
      
 
      <div class="clearfix"> 
 
    \t <label for="street_<cfoutput>#Add#</cfoutput>">Zip Code:</label> 
 
    \t <input type="text" name="postal_#Add#" required="yes" id="postal_code" size="8" maxlength="12" message="Please enter owner #Peoplecount#'s mailing zip code." value=""> 
 
    </div> 
 
     </div>

+0

इन उत्तरों में वर्णित एक्सेल में जावास्क्रिप्ट चलाने के लिए कुछ तकनीकें हैं: http://stackoverflow.com/questions/20171885/excel-macros-with-javascript http://stackoverflow.com/questions/848246/how- कैन-आई-यूज-जावास्क्रिप्ट-इन-ए-एक्सेल-मैक्रो – Starscream1984

+0

क्या आप कह रहे हैं कि यह संभव है? मुझे यह कहीं भी नहीं मिल रहा है। मैं यह पता लगाने में सक्षम था कि इसका नक्शा कैसे बनाया जाए, लेकिन स्वचालित पता कैसे करें –

+0

सैद्धांतिक रूप से संभव लगता है, लेकिन संभवतः आसान नहीं है। मैं इस बारे में बहुत उत्सुक हूं कि आप इसे पहले स्थान पर क्यों करना चाहते हैं? – Starscream1984

उत्तर

0

यह एक एक्सेल स्प्रेडशीट में मेरी jQuery स्क्रिप्ट का उपयोग करना संभव है? मैं एक स्वचालित पता भरने की सुविधा रखने के लिए भौगोलिक स्थान का उपयोग करने की कोशिश कर रहा हूं।

नहीं। आपकी स्क्रिप्ट Google मानचित्र API पर निर्भर है, और इसके लिए ब्राउज़र संदर्भ को ठीक से काम करने की आवश्यकता होगी।

जबकि आप Windows स्क्रिप्ट होस्ट में जावास्क्रिप्ट चला सकते हैं, तो आपको जावास्क्रिप्ट से कहीं अधिक की आवश्यकता है। आपको एक ब्राउज़र एपीआई चाहिए, जो भौगोलिक स्थान एपीआई और AJAX के साथ पूर्ण हो। आप Excel में नहीं पाएंगे।

हालांकि आप रचनात्मक हो सकते हैं। आप अपनी स्क्रिप्ट के साथ HTTP अनुरोध कर सकते हैं (हालांकि सामान्य AJAX तरीका नहीं)। आप शायद स्थिति पाने के लिए बाहरी एप्लिकेशन भी निष्पादित कर सकते हैं।

संबंधित मुद्दे