Geocoding API v4 में दो मुख्य सुविधाएं मिलती हैं: हाइपरलोकल एट्रिब्यूट के लिए डेस्टिनेशन सर्च और बुनियादी जियोकोडिंग (कोऑर्डिनेट-पते का कन्वर्ज़न). क्या आपको नहीं पता कि कौनसा तरीका इस्तेमाल करना चाहिए? जियोकोडिंग का तरीका चुनना देखें.
- डेस्टिनेशन खोजना (
SearchDestinations): इससे किसी डेस्टिनेशन पर पहुंचने के बारे में ज़्यादा जानकारी मिलती है. जैसे, इमारत के एंट्री पॉइंट, रूट किए जा सकने वाले नेविगेशन पॉइंट, इमारत/मैदान की आउटलाइन, सब-डेस्टिनेशन, और आस-पास की लोकप्रिय जगहें. - जियोकोडिंग (
GeocodeAddress): यह मोहल्ले के पतों को अक्षांश और देशांतर निर्देशांकों में बदलता है, ताकि बेसिक मार्कर लगाए जा सकें या मैप को बीच में लाया जा सके. - रिवर्स जियोकोडिंग (
GeocodeLocation): यह भौगोलिक निर्देशांकों को किसी व्यक्ति के लिए आसानी से पढ़े जा सकने वाले मोहल्ले के पते में बदलता है. - जगह की जियोकोडिंग (
GeocodePlace): इससे किसी जगह के आईडी के लिए, फ़ॉर्मैट किया गया पता और निर्देशांक मिलते हैं.
अनुरोधों और जवाबों के सैंपल
Geocoding API को एचटीटीपी इंटरफ़ेस के ज़रिए ऐक्सेस किया जाता है. यहां डेस्टिनेशन खोजने, फ़ॉरवर्ड जियोकोडिंग, और रिवर्स जियोकोडिंग के उदाहरण दिए गए हैं.
डेस्टिनेशन के लिए अनुरोध और जवाब (हाइपरलोकल अराइवल डेटा)
यहां दिए गए उदाहरण में, "1600 Amphitheatre Parkway, Mountain View, CA" के लिए, SearchDestinations को एचटीटीपी POST अनुरोध भेजा गया है. ध्यान दें कि SearchDestinations के लिए, X-Goog-FieldMask हेडर की ज़रूरत होती है. इसमें उन फ़ील्ड की जानकारी दी जाती है जिनकी वैल्यू आपको चाहिए:
curl -X POST -d '{ "addressQuery": { "addressQuery": "1600 Amphitheatre Parkway, Mountain View, CA" } }' \ -H 'Content-Type: application/json' \ -H 'X-Goog-FieldMask: destinations.primary.displayName,destinations.primary.formattedAddress,destinations.primary.location,destinations.primary.displayPolygon,destinations.entrances,destinations.navigationPoints,destinations.landmarks' \ -H "X-Goog-Api-Key: YOUR_API_KEY" \ "https://geocode.googleapis.com/v4/geocode/destinations"
यहां SearchDestinations के जवाब का एक सैंपल दिया गया है. इसमें बिल्डिंग फ़ुटप्रिंट पॉलीगॉन, पसंदीदा एंट्री पॉइंट, रूट किए जा सकने वाले नेविगेशन पॉइंट, और आस-पास के लैंडमार्क दिखाए गए हैं:
{ "destinations": [ { "primary": { "displayName": { "text": "Googleplex", "languageCode": "en" }, "formattedAddress": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "location": { "latitude": 37.4220656, "longitude": -122.0840897 }, "displayPolygon": { "type": "Polygon", "coordinates": [ [ [-122.084958, 37.422145], [-122.084112, 37.422610], [-122.083510, 37.421980], [-122.084958, 37.422145] ] ] } }, "entrances": [ { "location": { "latitude": 37.422189, "longitude": -122.084215 }, "tags": ["PREFERRED"] } ], "navigationPoints": [ { "navigationPointToken": "Eg...", "displayName": { "text": "Amphitheatre Pkwy Dropoff", "languageCode": "en" }, "location": { "latitude": 37.421912, "longitude": -122.084301 }, "travelModes": ["DRIVE"], "usages": ["DROPOFF", "PICKUP"] } ], "landmarks": [ { "place": { "displayName": { "text": "Charleston Park", "languageCode": "en" } }, "relationalDescription": { "text": "Adjacent to Charleston Park", "languageCode": "en" }, "straightLineDistanceMeters": 85.4 } ] } ] }
जियोकोडिंग का अनुरोध और जवाब (अक्षांश/देशांतर लुकअप)
यहां दिए गए उदाहरण में, "1600 Amphitheatre Parkway, Mountain View, CA" के अक्षांश और देशांतर का अनुरोध किया गया है. साथ ही, यह बताया गया है कि आउटपुट JSON फ़ॉर्मैट में होना चाहिए.
curl -H "X-Goog-Api-Key: YOUR_API_KEY" \ "https://geocode.googleapis.com/v4/geocode/address/1600+Amphitheatre+Parkway,+Mountain+View,+CA"
इसकी जांच करने के लिए, अपने वेब ब्राउज़र में यूआरएल डालें. ध्यान रहे कि YOUR_API_KEY को अपने असल एपीआई पासकोड से बदलें.
जवाब में पते का अक्षांश और देशांतर शामिल होता है.
जियोकोडिंग अनुरोध के यूआरएल बनाने, उपलब्ध पैरामीटर और रिस्पॉन्स को समझने के बारे में ज़्यादा जानकारी के लिए, डेवलपर की गाइड देखें.
यहां JSON में जियोकोडिंग के जवाब का एक सैंपल दिया गया है:
{ "results": [ { "place": "//places.googleapis.com/places/ChIJ2Z2idB66j4ARI43TG-9RoCQ", "placeId": "ChIJ2Z2idB66j4ARI43TG-9RoCQ", "location": { "latitude": 37.4438238, "longitude": -122.0869895 }, "granularity": "ROOFTOP", "viewport": { "low": { "latitude": 37.4424748197085, "longitude": -122.0883384802915 }, "high": { "latitude": 37.445172780291493, "longitude": -122.08564051970852 } }, "formattedAddress": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "postalAddress": { "regionCode": "US", "languageCode": "en", "postalCode": "94043-1351", "administrativeArea": "CA", "locality": "Mountain View", "addressLines": [ "1600 Amphitheatre Pkwy" ] }, "addressComponents": [ { "longText": "1600", "shortText": "1600", "types": [ "street_number" ] }, { "longText": "Amphitheatre Parkway", "shortText": "Amphitheatre Pkwy", "types": [ "route" ], "languageCode": "en" }, { "longText": "Mountain View", "shortText": "Mountain View", "types": [ "locality", "political" ], "languageCode": "en" }, { "longText": "Santa Clara County", "shortText": "Santa Clara County", "types": [ "administrative_area_level_2", "political" ], "languageCode": "en" }, { "longText": "California", "shortText": "CA", "types": [ "administrative_area_level_1", "political" ], "languageCode": "en" }, { "longText": "United States", "shortText": "US", "types": [ "country", "political" ], "languageCode": "en" }, { "longText": "94043", "shortText": "94043", "types": [ "postal_code" ] }, { "longText": "1351", "shortText": "1351", "types": [ "postal_code_suffix" ] } ], "types": [ "premise", "street_address" ] } ] }
रिवर्स जियोकोडिंग का अनुरोध और जवाब (पता देखना)
यहां दिए गए उदाहरण में, अमेरिका के न्यूयॉर्क के ब्रुकलिन में दिए गए अक्षांश/देशांतर के हिसाब से पते का अनुरोध किया गया है. इससे पता चलता है कि आउटपुट, JSON फ़ॉर्मैट में होना चाहिए.
https://geocode.googleapis.com/v4/geocode/location/37.4225508,-122.0846338?key=YOUR_API_KEYइसकी जांच करने के लिए, अपने वेब ब्राउज़र में यूआरएल डालें. 'YOUR_API_KEY' को अपने असल एपीआई पासकोड से बदलना न भूलें. जवाब में, अक्षांश और देशांतर की जगह के लिए, आसानी से पढ़ा जा सकने वाला पता शामिल होता है.
रिवर्स जियोकोडिंग के अनुरोध वाले यूआरएल बनाने, उपलब्ध पैरामीटर, और जवाब को समझने के बारे में ज़्यादा जानकारी के लिए, डेवलपर की गाइड देखें.
यहां JSON में, रिवर्स जियोकोडिंग के जवाब का एक सैंपल दिया गया है:
{ "results": [ { "place": "//places.googleapis.com/places/ChIJHRNUiQK6j4ARJ__Hrbt6qsE", "placeId": "ChIJHRNUiQK6j4ARJ__Hrbt6qsE", "location": { "latitude": 37.4225657, "longitude": -122.08465439999999 }, "granularity": "ROOFTOP", "viewport": { "low": { "latitude": 37.421214719708509, "longitude": -122.08603273029148 }, "high": { "latitude": 37.423912680291508, "longitude": -122.0833347697085 } }, "bounds": { "low": { "latitude": 37.4225178, "longitude": -122.08484599999998 }, "high": { "latitude": 37.422609600000008, "longitude": -122.0845215 } }, "formattedAddress": "Google Building 40, 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "postalAddress": { "regionCode": "US", "languageCode": "en", "postalCode": "94043", "administrativeArea": "CA", "locality": "Mountain View", "addressLines": [ "Google Building 40", "1600 Amphitheatre Pkwy" ] }, "addressComponents": [ { "longText": "Google Building 40", "shortText": "Google Building 40", "types": [ "premise" ], "languageCode": "en" }, { "longText": "1600", "shortText": "1600", "types": [ "street_number" ] }, { "longText": "Amphitheatre Parkway", "shortText": "Amphitheatre Pkwy", "types": [ "route" ], "languageCode": "en" }, { "longText": "Mountain View", "shortText": "Mountain View", "types": [ "locality", "political" ], "languageCode": "en" }, { "longText": "Santa Clara County", "shortText": "Santa Clara County", "types": [ "administrative_area_level_2", "political" ], "languageCode": "en" }, { "longText": "California", "shortText": "CA", "types": [ "administrative_area_level_1", "political" ], "languageCode": "en" }, { "longText": "United States", "shortText": "US", "types": [ "country", "political" ], "languageCode": "en" }, { "longText": "94043", "shortText": "94043", "types": [ "postal_code" ] } ], "types": [ "street_address", "subpremise" ] }, ... Additional results truncated in this example[] ... }
पुष्टि करना, कोटा, कीमत, और नीतियां
पुष्टि करना
Geocoding API का इस्तेमाल करने के लिए, आपको पहले एपीआई को चालू करना होगा. साथ ही, पुष्टि करने के लिए सही क्रेडेंशियल पाने होंगे. ज़्यादा जानकारी के लिए, Google Maps Platform का इस्तेमाल शुरू करना लेख पढ़ें.
कोटा और कीमत
Geocoding API के लिए तय किए गए कोटे और कीमत के बारे में जानकारी पाने के लिए, इस्तेमाल और बिलिंग पेज देखें.
नीतियां
Geocoding API का इस्तेमाल, एपीआई की नीतियों के मुताबिक होना चाहिए.