রুট হল শুরু করার লোকেশন বা উৎস এবং শেষ করার লোকেশন বা গন্তব্যের মধ্যে নেভিগেট করার পথ। আপনি হাঁটা, বাইক চালানো বা বিভিন্ন ধরনের যানবাহনের মতো বিভিন্ন ধরনের পরিবহনের জন্য রুট বেছে নিতে পারেন। এছাড়াও, আপনি রুটের বিবরণ যেমন দূরত্ব, রুট নেভিগেট করার আনুমানিক সময়, সম্ভাব্য টোল এবং রুট নেভিগেট করার জন্য ধাপে-ধাপে নির্দেশাবলীর জন্য অনুরোধ করতে পারেন।
সম্পূর্ণ উদাহরণ সোর্স কোড দেখুন
নিম্নলিখিত কোড স্যাম্পেল থেকে জানা যায় যে দুটি লোকেশনের মধ্যে গাড়ি চালানোর দিকনির্দেশের জন্য কীভাবে রুট পাওয়া যায়।
TypeScript
// Initialize and add the map. let map: google.maps.Map; let mapPolylines: google.maps.Polyline[] = []; const center = { lat: 37.447646, lng: -122.113878 }; // Palo Alto, CA // Initialize and add the map. async function init(): Promise<void> { // Request the needed libraries. const [{ Map }, { Place }, { Route }] = await Promise.all([ google.maps.importLibrary('maps'), google.maps.importLibrary('places'), google.maps.importLibrary('routes'), ]); map = new Map(document.getElementById('map')!, { zoom: 12, center, mapTypeControl: false, mapId: 'DEMO_MAP_ID', }); // Use address strings in a directions request. const requestWithAddressStrings = { origin: '1600 Amphitheatre Parkway, Mountain View, CA', destination: '345 Spear Street, San Francisco, CA', fields: ['path'], }; console.log({ requestWithAddressStrings }); // Use Place IDs in a directions request. const originPlaceInstance = new Place({ id: 'ChIJiQHsW0m3j4ARm69rRkrUF3w', // Mountain View, CA }); const destinationPlaceInstance = new Place({ id: 'ChIJIQBpAG2ahYAR_6128GcTUEo', // San Francisco, CA }); const requestWithPlaceIds: google.maps.routes.ComputeRoutesRequest = { origin: originPlaceInstance, destination: destinationPlaceInstance, fields: ['path'], // Request fields needed to draw polylines. }; console.log({ requestWithPlaceIds }); // Use lat/lng in a directions request. // Mountain View, CA const originLatLng = { lat: 37.422, lng: -122.084058 }; // San Francisco, CA const destinationLatLng = { lat: 37.774929, lng: -122.419415 }; // Define a computeRoutes request. const requestWithLatLngs: google.maps.routes.ComputeRoutesRequest = { origin: originLatLng, destination: destinationLatLng, fields: ['path'], }; console.log({ requestWithLatLngs }); // Use Plus Codes in a directions request. const requestWithPlusCodes: google.maps.routes.ComputeRoutesRequest = { origin: '849VCWC8+R9', // Mountain View, CA destination: 'CRHJ+C3 Stanford, CA 94305, USA', // Stanford, CA fields: ['path'], }; console.log({ requestWithPlusCodes }); // Define a routes request. const request: google.maps.routes.ComputeRoutesRequest = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', travelMode: 'DRIVING', fields: ['path'], // Request fields needed to draw polylines. }; // Call computeRoutes to get the directions. const { routes } = await Route.computeRoutes(request); // Use createPolylines to create polylines for the route. if (!routes) { console.warn('No routes found.'); return; } mapPolylines = routes[0].createPolylines(); // Add polylines to the map. mapPolylines.forEach((polyline) => { polyline.setMap(map); }); // Create markers to start and end points. const markers = await routes[0].createWaypointAdvancedMarkers(); // Add markers to the map markers.forEach((marker) => { marker.map = map; }); // Display the raw JSON for the result in the console. console.log(`Response:\n ${JSON.stringify(routes, null, 2)}`); // Fit the map to the path. void fitMapToPath(routes[0].path!); } // Helper function to fit the map to the path. async function fitMapToPath(path: google.maps.LatLngLiteral[]) { const { LatLngBounds } = await google.maps.importLibrary('core'); const bounds = new LatLngBounds(); path.forEach((point) => { bounds.extend(point); }); map.fitBounds(bounds); } void init();
জাভাস্ক্রিপ্ট
// Initialize and add the map. let map; let mapPolylines = []; const center = { lat: 37.447646, lng: -122.113878 }; // Palo Alto, CA // Initialize and add the map. async function init() { // Request the needed libraries. const [{ Map }, { Place }, { Route }] = await Promise.all([ google.maps.importLibrary('maps'), google.maps.importLibrary('places'), google.maps.importLibrary('routes'), ]); map = new Map(document.getElementById('map'), { zoom: 12, center, mapTypeControl: false, mapId: 'DEMO_MAP_ID', }); // Use address strings in a directions request. const requestWithAddressStrings = { origin: '1600 Amphitheatre Parkway, Mountain View, CA', destination: '345 Spear Street, San Francisco, CA', fields: ['path'], }; console.log({ requestWithAddressStrings }); // Use Place IDs in a directions request. const originPlaceInstance = new Place({ id: 'ChIJiQHsW0m3j4ARm69rRkrUF3w', // Mountain View, CA }); const destinationPlaceInstance = new Place({ id: 'ChIJIQBpAG2ahYAR_6128GcTUEo', // San Francisco, CA }); const requestWithPlaceIds = { origin: originPlaceInstance, destination: destinationPlaceInstance, fields: ['path'], // Request fields needed to draw polylines. }; console.log({ requestWithPlaceIds }); // Use lat/lng in a directions request. // Mountain View, CA const originLatLng = { lat: 37.422, lng: -122.084058 }; // San Francisco, CA const destinationLatLng = { lat: 37.774929, lng: -122.419415 }; // Define a computeRoutes request. const requestWithLatLngs = { origin: originLatLng, destination: destinationLatLng, fields: ['path'], }; console.log({ requestWithLatLngs }); // Use Plus Codes in a directions request. const requestWithPlusCodes = { origin: '849VCWC8+R9', // Mountain View, CA destination: 'CRHJ+C3 Stanford, CA 94305, USA', // Stanford, CA fields: ['path'], }; console.log({ requestWithPlusCodes }); // Define a routes request. const request = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', travelMode: 'DRIVING', fields: ['path'], // Request fields needed to draw polylines. }; // Call computeRoutes to get the directions. const { routes } = await Route.computeRoutes(request); // Use createPolylines to create polylines for the route. if (!routes) { console.warn('No routes found.'); return; } mapPolylines = routes[0].createPolylines(); // Add polylines to the map. mapPolylines.forEach((polyline) => { polyline.setMap(map); }); // Create markers to start and end points. const markers = await routes[0].createWaypointAdvancedMarkers(); // Add markers to the map markers.forEach((marker) => { marker.map = map; }); // Display the raw JSON for the result in the console. console.log(`Response:\n ${JSON.stringify(routes, null, 2)}`); // Fit the map to the path. void fitMapToPath(routes[0].path); } // Helper function to fit the map to the path. async function fitMapToPath(path) { const { LatLngBounds } = await google.maps.importLibrary('core'); const bounds = new LatLngBounds(); path.forEach((point) => { bounds.extend(point); }); map.fitBounds(bounds); } void init();
CSS
/* * Always set the map height explicitly to define the size of the div element * that contains the map. */ #map { height: 100%; } /* * Optional: Makes the sample page fill the window. */ html, body { height: 100%; margin: 0; padding: 0; }
HTML
<html>
<head>
<title>Get directions</title>
<link rel="stylesheet" type="text/css" href="./style.css" />
<script type="module" src="./index.js"></script>
<script>
// prettier-ignore
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "GOOGLE_MAPS_API_KEY"
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>স্যাম্পেল ব্যবহার করে দেখুন
দুটি লোকেশনের মধ্যে রুট সংক্রান্ত অনুরোধ করতে computeRoutes()
মেথড কল করুন। নিম্নলিখিত উদাহরণে দেখানো হয়েছে কীভাবে একটি
অনুরোধ সংজ্ঞায়িত করতে হয় এবং তারপর রুট পেতে computeRoutes() কল করতে হয়।
computeRoutes() হল Route
ক্লাসের স্ট্যাটিক পদ্ধতি, তাই সরাসরি Route.computeRoutes(request) কল করুন। এছাড়াও, অনুরোধে অবশ্যই fields প্রপার্টিকে রেসপন্স ফিল্ড মাস্ক হিসেবে সেট করতে হবে।
// Import the Routes library. const { Route } = await google.maps.importLibrary('routes'); // Define a computeRoutes request. const request = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', fields: ['path'], // Required: response field mask. }; // Call the computeRoutes() method to get routes. const {routes} = await Route.computeRoutes(request);
ম্যাপে রুট আঁকতে,
createPolylines()
কল করুন, যে রুটের জন্য আপনি path ফিল্ডের মাধ্যমে অনুরোধ করেছেন। ম্যাপে পলিলাইন দেখানো
দেখুন।
ফেরত দেওয়ার জন্য ফিল্ড বেছে নিন
আপনি কোনও রুটের জন্য অনুরোধ করলে, উত্তরে কী তথ্য ফেরত দেওয়া উচিত তা নির্দিষ্ট করতে আপনাকে অবশ্যই একটি ফিল্ড মাস্ক ব্যবহার করতে হবে। আপনি ফিল্ড মাস্কে রুট ক্লাস প্রপার্টি-এর নাম উল্লেখ করতে পারেন।
এছাড়াও, ফিল্ড মাস্ক ব্যবহার করলে আপনি অপ্রয়োজনীয় ডেটার জন্য অনুরোধ করবেন না, যা রেসপন্স লেটেন্সির ক্ষেত্রে সাহায্য করে এবং আপনার সিস্টেমের প্রয়োজন নেই এমন তথ্য ফেরত পাঠানো এড়ায়।
আপনার প্রয়োজনীয় ফিল্ডের তালিকা নির্দিষ্ট করতে
ComputeRoutesRequest.fields
প্রপার্টি সেট করুন, যেমনটি নিম্নলিখিত স্নিপেটে দেখানো হয়েছে:
TypeScript
// Define a routes request. const request: google.maps.routes.ComputeRoutesRequest = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', travelMode: 'DRIVING', fields: ['path'], // Request fields needed to draw polylines. };
জাভাস্ক্রিপ্ট
// Define a routes request. const request = { origin: 'Mountain View, CA', destination: 'San Francisco, CA', travelMode: 'DRIVING', fields: ['path'], // Request fields needed to draw polylines. };
কোনও রুটের জন্য লোকেশন উল্লেখ করুন
রুট গণনা করতে, আপনাকে অবশ্যই রুটের শুরু এবং রুটের গন্তব্যের অবস্থান এবং একটি ফিল্ড মাস্ক উল্লেখ করতে হবে। এছাড়াও, আপনি কোনও রুটের মধ্যবর্তী ওয়েপয়েন্ট নির্দিষ্ট করতে পারেন এবং কোনও রুটে স্টপ বা পাসথ্রু পয়েন্ট যোগ করার মতো অন্যান্য কাজ করতে ওয়েপয়েন্ট ব্যবহার করতে পারেন।
ComputeRoutesRequest-এ, আপনি নিম্নলিখিত যেকোনও উপায়ে লোকেশন নির্দিষ্ট করতে
পারবেন:
- জায়গা (পছন্দের)
- অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট
- ঠিকানার স্ট্রিং ("শিকাগো, IL" বা "ডারউইন, NT, অস্ট্রেলিয়া")
- Plus Code
আপনি একই উপায়ে কোনও অনুরোধে সব ওয়েপয়েন্টের জন্য লোকেশন নির্দিষ্ট করতে পারেন অথবা আপনি সেগুলি মিক্স করতে পারেন। যেমন, আপনি সোর্স ওয়েপয়েন্টের জন্য অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক এবং ডেস্টিনেশন ওয়েপয়েন্টের জন্য Place অবজেক্ট ব্যবহার করতে পারেন।
দক্ষতা ও নির্ভুলতার জন্য, অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক বা ঠিকানা স্ট্রিংয়ের পরিবর্তে জায়গার অবজেক্ট ব্যবহার করুন। প্লেস আইডি অনন্যভাবে স্পষ্ট এবং রাউটিংয়ের জন্য জিওকোডিং সুবিধা প্রদান করে যেমন অ্যাক্সেস পয়েন্ট এবং ট্রাফিক ভেরিয়েবল। অন্য উপায়ে লোকেশন উল্লেখ করার ফলে যেসব পরিস্থিতি তৈরি হতে পারে, সেগুলি এড়াতে এগুলি সাহায্য করে:
- অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট ব্যবহার করলে, লোকেশনটি সেই কোঅর্ডিনেটের সবচেয়ে কাছের রাস্তায় স্ন্যাপ করা হতে পারে - যা প্রপার্টিতে অ্যাক্সেস পয়েন্ট নাও হতে পারে, এমনকি এমন একটি রাস্তা যা দ্রুত বা নিরাপদে গন্তব্যে নিয়ে যায়।
- রুট গণনা করার আগে, ঠিকানা স্ট্রিংগুলিকে প্রথমে Routes API দ্বারা জিওকোড করতে হবে যাতে সেগুলিকে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্কে রূপান্তর করা যায়। এই কনভার্সন পারফর্ম্যান্সকে প্রভাবিত করতে পারে।
কোনও লোকেশনকে জায়গা অবজেক্ট হিসেবে উল্লেখ করুন (পছন্দসই)
কোনও জায়গা ব্যবহার করে লোকেশন নির্দিষ্ট করতে, নতুন Place ইনস্ট্যান্স তৈরি করুন। নিচের
স্নিপেট থেকে বোঝা যায় যে কীভাবে origin
এবং destination-এর জন্য নতুন Place ইনস্ট্যান্স তৈরি করতে হয় এবং তারপর ComputeRoutesRequest-এ সেগুলি ব্যবহার করতে হয়:
TypeScript
// Use Place IDs in a directions request. const originPlaceInstance = new Place({ id: 'ChIJiQHsW0m3j4ARm69rRkrUF3w', // Mountain View, CA }); const destinationPlaceInstance = new Place({ id: 'ChIJIQBpAG2ahYAR_6128GcTUEo', // San Francisco, CA }); const requestWithPlaceIds: google.maps.routes.ComputeRoutesRequest = { origin: originPlaceInstance, destination: destinationPlaceInstance, fields: ['path'], // Request fields needed to draw polylines. };
জাভাস্ক্রিপ্ট
// Use Place IDs in a directions request. const originPlaceInstance = new Place({ id: 'ChIJiQHsW0m3j4ARm69rRkrUF3w', // Mountain View, CA }); const destinationPlaceInstance = new Place({ id: 'ChIJIQBpAG2ahYAR_6128GcTUEo', // San Francisco, CA }); const requestWithPlaceIds = { origin: originPlaceInstance, destination: destinationPlaceInstance, fields: ['path'], // Request fields needed to draw polylines. };
অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট
অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক হিসেবে কোনও লোকেশন নির্দিষ্ট করতে, নতুন
google.maps.LatLngLiteral, google.maps.LatLngAltitude, অথবা
google.maps.LatLngAltitudeLiteral ইনস্ট্যান্স তৈরি করুন। নিম্নলিখিত স্নিপেট থেকে বোঝা যায় যে,
origin ও destination-এর জন্য নতুন google.maps.LatLngLiteral ইনস্ট্যান্স তৈরি করা
এবং তারপর computeRoutesRequest-এ সেগুলি ব্যবহার করা:
TypeScript
// Use lat/lng in a directions request. // Mountain View, CA const originLatLng = { lat: 37.422, lng: -122.084058 }; // San Francisco, CA const destinationLatLng = { lat: 37.774929, lng: -122.419415 }; // Define a computeRoutes request. const requestWithLatLngs: google.maps.routes.ComputeRoutesRequest = { origin: originLatLng, destination: destinationLatLng, fields: ['path'], };
জাভাস্ক্রিপ্ট
// Use lat/lng in a directions request. // Mountain View, CA const originLatLng = { lat: 37.422, lng: -122.084058 }; // San Francisco, CA const destinationLatLng = { lat: 37.774929, lng: -122.419415 }; // Define a computeRoutes request. const requestWithLatLngs = { origin: originLatLng, destination: destinationLatLng, fields: ['path'], };
ঠিকানার স্ট্রিং
ঠিকানার স্ট্রিং হল স্ট্রিং দ্বারা উপস্থাপিত আক্ষরিক ঠিকানা (যেমন "১৬০০ অ্যাম্ফিথিয়েটার পার্কওয়ে, মাউন্টেন ভিউ, ক্যালিফোর্নিয়া")। জিওকোডিং হল কোনও ঠিকানার স্ট্রিংকে অক্ষাংশ ও দ্রাঘিমাংশ স্থানাঙ্কে (যেমন, অক্ষাংশ ৩৭.৪২৩০২১ এবং দ্রাঘিমাংশ -১২২.০৮৩৭৩৯) পরিবর্তন করার প্রসেস।
আপনি যখন কোনও ওয়েপয়েন্টের লোকেশন হিসেবে অ্যাড্রেস স্ট্রিং পাস করেন, তখন Routes লাইব্রেরি অভ্যন্তরীণভাবে স্ট্রিংটিকে জিওকোড করে অক্ষাংশ ও দ্রাঘিমাংশ কোঅর্ডিনেটে কনভার্ট করে।
নিম্নলিখিত স্নিপেট থেকে দেখা যায় যে, origin ও destination-এর জন্য অ্যাড্রেস স্ট্রিং সহ
ComputeRoutesRequest তৈরি করা হচ্ছে:
TypeScript
// Use address strings in a directions request. const requestWithAddressStrings = { origin: '1600 Amphitheatre Parkway, Mountain View, CA', destination: '345 Spear Street, San Francisco, CA', fields: ['path'], };
জাভাস্ক্রিপ্ট
// Use address strings in a directions request. const requestWithAddressStrings = { origin: '1600 Amphitheatre Parkway, Mountain View, CA', destination: '345 Spear Street, San Francisco, CA', fields: ['path'], };
ঠিকানার জন্য অঞ্চল সেট করুন
আপনি যদি কোনও ওয়েপয়েন্টের লোকেশন হিসেবে অসম্পূর্ণ অ্যাড্রেস স্ট্রিং পাস করেন, তাহলে API ভুল জিওকোড করা অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট ব্যবহার করতে পারে। যেমন, আপনি ড্রাইভিং রুটের জন্য "টলেডো" থেকে "মাদ্রিদ" পর্যন্ত অনুরোধ করেছেন:
// Define a request with an incomplete address string. const request = { origin: 'Toledo', destination: 'Madrid', };
এই উদাহরণে, "টলেডো" বলতে স্পেনের কোনও শহর নয়, মার্কিন যুক্তরাষ্ট্রের ওহাইও রাজ্যের একটি শহরকে বোঝানো হয়েছে। তাই, অনুরোধটি একটি খালি অ্যারে রিটার্ন করে, যার অর্থ হল কোনও রুট নেই।
আপনি API কনফিগার করতে পারেন যাতে regionCode প্যারামিটার অন্তর্ভুক্ত করে কোনও নির্দিষ্ট অঞ্চলের জন্য পক্ষপাতদুষ্ট ফলাফল পাওয়া যায়। এই প্যারামিটারটি ccTLD ("টপ-লেভেল ডোমেন") দুটি অক্ষরের মান হিসেবে অঞ্চল কোড নির্দিষ্ট করে। বেশিরভাগ ccTLD কোড ISO 3166-1 কোডের মতোই, তবে কিছু উল্লেখযোগ্য ব্যতিক্রম আছে। যেমন, যুক্তরাজ্যের ccTLD হল "uk" (.co.uk) এবং এর ISO 3166-1 কোড হল "gb" (টেকনিক্যালি "The United Kingdom of Great Britain and Northern Ireland" এন্টিটির জন্য)।
"Toledo" থেকে "Madrid" পর্যন্ত দিকনির্দেশের অনুরোধে regionCode প্যারামিটার অন্তর্ভুক্ত থাকলে, সঠিক ফলাফল পাওয়া যায় কারণ "Toledo" স্পেনের একটি শহর হিসেবে ব্যাখ্যা করা হয়:
const request = { origin: 'Toledo', destination: 'Madrid', region: 'es', // Specify the region code for Spain. };
Plus Code
অনেকেরই সঠিক ঠিকানা নেই, যার ফলে তাদের ডেলিভারি পেতে অসুবিধা হতে পারে। অথবা, কোনও ঠিকানায় থাকা লোকজন আরও নির্দিষ্ট লোকেশনে ডেলিভারি নিতে পছন্দ করতে পারেন, যেমন, পিছনের প্রবেশপথ বা লোডিং ডক।
Plus Code হল এমন ব্যক্তি বা জায়গার রাস্তার ঠিকানা যার কোনও আসল ঠিকানা নেই। রাস্তার নাম ও নম্বর সহ ঠিকানার পরিবর্তে, Plus Code অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্কের উপর ভিত্তি করে তৈরি হয় এবং সংখ্যা ও অক্ষর হিসেবে দেখানো হয়।
প্রত্যেক ব্যক্তি ও জায়গার জন্য ঠিকানা সংক্রান্ত সুবিধা প্রদান করতে, Google Plus Code তৈরি করেছে। Plus Code হল একটি এনকোড করা লোকেশন রেফারেন্স, যা অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক থেকে প্রাপ্ত, যা একটি এলাকাকে উপস্থাপন করে: ১/৮০০০ ডিগ্রি বাই ১/৮০০০ ডিগ্রি (নিরক্ষরেখায় প্রায় ১৪মি x ১৪মি) বা তার চেয়ে ছোট। যেসব জায়গায় রাস্তার ঠিকানা নেই অথবা বিল্ডিংয়ের নম্বর বা রাস্তার নাম নেই, সেখানে রাস্তার ঠিকানার পরিবর্তে Plus Code ব্যবহার করতে পারেন।
Plus Code অবশ্যই গ্লোবাল কোড বা কম্পাউন্ড কোড হিসেবে ফর্ম্যাট করতে হবে:
- গ্লোবাল কোড ৪ অক্ষরের এলাকার কোড এবং ৬ অক্ষর বা তার বেশি দৈর্ঘ্যের স্থানীয় কোড নিয়ে তৈরি হয়। যেমন, "১৬০০ অ্যাম্ফিথিয়েটার পার্কওয়ে, মাউন্টেন ভিউ, ক্যালিফোর্নিয়া" ঠিকানার জন্য গ্লোবাল কোড হল "849V" এবং লোকাল কোড হল "CWC8+R9"। তারপর আপনি লোকেশন ভ্যালু "849VCWC8+R9" হিসেবে নির্দিষ্ট করতে ১০টি অক্ষর বিশিষ্ট সম্পূর্ণ Plus Code ব্যবহার করেন।
- কম্পাউন্ড কোড ৬টি অক্ষর বা তার বেশি দৈর্ঘ্যের স্থানীয় কোড এবং নির্দিষ্ট লোকেশন নিয়ে তৈরি হয়। যেমন, "450 Serra Mall, Stanford, CA 94305, USA" ঠিকানার স্থানীয় কোড হল "CRHJ+C3"। কম্পাউন্ড ঠিকানার জন্য, স্থানীয় কোডের সাথে শহর, রাজ্য, পিন কোড এবং দেশের নাম যোগ করে "CRHJ+C3 Stanford, CA 94305, USA" ফর্ম্যাটে লিখুন।
নিম্নলিখিত স্নিপেট থেকে জানা যায় যে Plus Code ব্যবহার করে রুটের শুরু ও গন্তব্যের জন্য ওয়েপয়েন্ট নির্দিষ্ট করে কীভাবে রুট গণনা করা হয়:
TypeScript
// Use Plus Codes in a directions request. const requestWithPlusCodes: google.maps.routes.ComputeRoutesRequest = { origin: '849VCWC8+R9', // Mountain View, CA destination: 'CRHJ+C3 Stanford, CA 94305, USA', // Stanford, CA fields: ['path'], };
জাভাস্ক্রিপ্ট
// Use Plus Codes in a directions request. const requestWithPlusCodes = { origin: '849VCWC8+R9', // Mountain View, CA destination: 'CRHJ+C3 Stanford, CA 94305, USA', // Stanford, CA fields: ['path'], };