Class Geocoder

Geocoder

इस कुकी की मदद से, पते और भौगोलिक निर्देशांकों को आपस में बदला जा सकता है.
नीचे दिए गए उदाहरण में बताया गया है कि इस क्लास का इस्तेमाल करके, कोलोराडो में "Main St" के लिए सबसे ज़्यादा नौ मैच कैसे ढूंढे जा सकते हैं. साथ ही, उन्हें मैप में जोड़कर, नए Google दस्तावेज़ में कैसे एम्बेड किया जा सकता है.

// Find the best matches for "Main St" in Colorado.
const response = Maps.newGeocoder()
                     // The latitudes and longitudes of southwest and northeast
                     // corners of Colorado, respectively.
                     .setBounds(36.998166, -109.045486, 41.001666, -102.052002)
                     .geocode('Main St');

// Create a Google Doc and map.
const doc = DocumentApp.create('My Map');
const map = Maps.newStaticMap();

// Add each result to the map and doc.
for (let i = 0; i < response.results.length && i < 9; i++) {
  const result = response.results[i];
  map.setMarkerStyle(null, null, i + 1);
  map.addMarker(result.geometry.location.lat, result.geometry.location.lng);
  doc.appendListItem(result.formatted_address);
}

// Add the finished map to the doc.
doc.appendImage(Utilities.newBlob(map.getMapImage(), 'image/png'));

इन्हें भी देखें

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
geocode(address)Objectयह फ़ंक्शन, दिए गए पते के लिए अनुमानित भौगोलिक पॉइंट देता है.
reverseGeocode(latitude, longitude)Objectयह फ़ंक्शन, किसी भौगोलिक पॉइंट के लिए अनुमानित पते दिखाता है.
setBounds(swLatitude, swLongitude, neLatitude, neLongitude)Geocoderयह पैरामीटर, उस इलाके की सीमाएं सेट करता है जिसे नतीजों में ज़्यादा प्राथमिकता दी जानी चाहिए.
setLanguage(language)Geocoderइस कुकी का इस्तेमाल, नतीजों में इस्तेमाल की जाने वाली भाषा को सेट करने के लिए किया जाता है.
setRegion(region)Geocoderजगह के नामों को समझने के लिए, क्षेत्र सेट करता है.

ज़्यादा जानकारी वाला दस्तावेज़

geocode(address)

यह फ़ंक्शन, दिए गए पते के लिए अनुमानित भौगोलिक पॉइंट देता है.

// Gets the geographic coordinates for Times Square.
const response = Maps.newGeocoder().geocode('Times Square, New York, NY');
for (let i = 0; i < response.results.length; i++) {
  const result = response.results[i];
  Logger.log(
      '%s: %s, %s',
      result.formatted_address,
      result.geometry.location.lat,
      result.geometry.location.lng,
  );
}

पैरामीटर

नामटाइपब्यौरा
addressStringकोई पता.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है, जिसमें जियोकोडिंग डेटा होता है. इसके बारे में यहां बताया गया है.


reverseGeocode(latitude, longitude)

यह फ़ंक्शन, किसी भौगोलिक पॉइंट के लिए अनुमानित पते दिखाता है.

// Gets the address of a point in Times Square.
const response = Maps.newGeocoder().reverseGeocode(40.758577, -73.984464);
for (let i = 0; i < response.results.length; i++) {
  const result = response.results[i];
  Logger.log(
      '%s: %s, %s',
      result.formatted_address,
      result.geometry.location.lat,
      result.geometry.location.lng,
  );
}

पैरामीटर

नामटाइपब्यौरा
latitudeNumberपॉइंट का अक्षांश.
longitudeNumberपॉइंट का देशांतर.

वापसी का टिकट

Object — यह एक JSON ऑब्जेक्ट है. इसमें रिवर्स जियोकोडिंग का डेटा होता है. इसके बारे में यहां बताया गया है.

इन्हें भी देखें


setBounds(swLatitude, swLongitude, neLatitude, neLongitude)

यह पैरामीटर, उस इलाके की सीमाएं सेट करता है जिसे नतीजों में ज़्यादा प्राथमिकता दी जानी चाहिए.

// Creates a Geocoder that prefers points in the area of Manhattan.
const geocoder = Maps.newGeocoder().setBounds(
    40.699642,
    -74.021072,
    40.877569,
    -73.908548,
);

पैरामीटर

नामटाइपब्यौरा
swLatitudeNumberबाउंड्री के दक्षिण-पश्चिम कोने का अक्षांश.
swLongitudeNumberबाउंड के दक्षिण-पश्चिम कोने का देशांतर.
neLatitudeNumberयह बाउंड्री के उत्तर-पूर्वी कोने का अक्षांश होता है.
neLongitudeNumberबाउंड के उत्तर-पूर्वी कोने का देशांतर.

वापसी का टिकट

Geocoder — यह Geocoder ऑब्जेक्ट है. इससे कॉल को एक साथ कई बार किया जा सकता है.

इन्हें भी देखें


setLanguage(language)

इस कुकी का इस्तेमाल, नतीजों में इस्तेमाल की जाने वाली भाषा को सेट करने के लिए किया जाता है.

// Creates a Geocoder with the language set to French.
const geocoder = Maps.newGeocoder().setLanguage('fr');

पैरामीटर

नामटाइपब्यौरा
languageStringBCP-47 भाषा आइडेंटिफ़ायर.

वापसी का टिकट

Geocoder — यह Geocoder ऑब्जेक्ट है. इससे कॉल को एक साथ कई बार किया जा सकता है.

इन्हें भी देखें


setRegion(region)

जगह के नामों को समझने के लिए, क्षेत्र सेट करता है. जिन देशों/इलाकों के कोड इस्तेमाल किए जा सकते हैं वे Google Maps के साथ काम करने वाले सीसीटीएलडी से मेल खाते हैं. उदाहरण के लिए, क्षेत्र कोड "uk" का मतलब "maps.google.co.uk" है.

// Creates a Geocoder with the region set to France.
const geocoder = Maps.newGeocoder().setRegion('fr');

पैरामीटर

नामटाइपब्यौरा
regionStringइस्तेमाल करने के लिए क्षेत्र का कोड.

वापसी का टिकट

Geocoder — यह Geocoder ऑब्जेक्ट है. इससे कॉल को एक साथ कई बार किया जा सकता है.

इन्हें भी देखें