কোনও একটি রুট বেছে নিন

ইউরোপীয় অর্থনৈতিক অঞ্চল (EEA)-এর ডেভেলপার

রুট হল যাত্রা শুরুর লোকেশন বা অরিজিন এবং গন্তব্য লোকেশনের মধ্যে নেভিগেট করা যায় এমন পাথ। আপনি হাঁটা, বাইক চালানো বা বিভিন্ন ধরনের যানবাহনের মতো বিভিন্ন ধরনের পরিবহন মোডের জন্য রুট পেতে পারেন। এছাড়াও, আপনি রুট সংক্রান্ত বিবরণ যেমন, দূরত্ব, রুট নেভিগেট করার আনুমানিক সময়, সম্ভাব্য টোল এবং রুট নেভিগেট করার জন্য ধাপে ধাপে নির্দেশাবলী জানতে চাইতে পারেন।

সম্পূর্ণ উদাহরণ সোর্স কোড দেখুন

নিচের কোড স্যাম্পেল থেকে দুটি লোকেশনের মধ্যে ড্রাইভিং দিকনির্দেশের রুট কীভাবে পাবেন তা জানতে পারবেন।

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() কীভাবে কল করতে হয় তা দেখানো হয়েছে।

  // 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',
  };

  // Call the computeRoutes() method to get routes.
  const {routes} = await Route.computeRoutes(request);
    

ফেরত দেওয়ার জন্য ফিল্ড বেছে নিন

আপনি কোনও রুটের অনুরোধ করলে, উত্তরে কী কী তথ্য থাকতে হবে তা নির্দিষ্ট করতে আপনাকে অবশ্যই ফিল্ড মাস্ক ব্যবহার করতে হবে। আপনি ফিল্ড মাস্কে রাউট ক্লাস প্রপার্টি -এর নাম উল্লেখ করতে পারবেন।

ফিল্ড মাস্ক ব্যবহার করলে, আপনি যে অপ্রয়োজনীয় ডেটা অনুরোধ করেন না, সেটিও নিশ্চিত করা যায়। এর ফলে, উত্তর দেওয়ার লেটেন্সি কমে যায় এবং আপনার সিস্টেমের প্রয়োজন নেই এমন তথ্য আর ফেরত আসে না।

নিচের স্নিপেটে দেখানো 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-এ, আপনি নিম্নলিখিত পদ্ধতিগুলির যেকোনও একটিতে লোকেশন নির্দিষ্ট করতে পারবেন:

আপনি কোনও অনুরোধে সমস্ত ওয়েপয়েন্টের জন্য একই পদ্ধতিতে লোকেশন নির্দিষ্ট করতে পারেন অথবা সেগুলি মিশিয়ে দিতে পারেন। যেমন, আপনি অরিজিন ওয়েপয়েন্টের জন্য অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট ব্যবহার করতে পারেন এবং গন্তব্য ওয়েপয়েন্টের জন্য প্লেস অবজেক্ট ব্যবহার করতে পারেন।

দক্ষতা ও নির্ভুলতার জন্য, অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট বা অ্যাড্রেস স্ট্রিংয়ের পরিবর্তে 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'],
};

ঠিকানার স্ট্রিং

ঠিকানার স্ট্রিং হল স্ট্রিংয়ের মাধ্যমে দেখানো আক্ষরিক ঠিকানা (যেমন, "1600 Amphitheatre Parkway, Mountain View, CA")। জিওকোডিং হল একটি অ্যাড্রেস স্ট্রিংকে অক্ষাংশ ও দ্রাঘিমাংশ কোঅর্ডিনেটে (যেমন, অক্ষাংশ 37.423021 এবং দ্রাঘিমাংশ -122.083739) কনভার্ট করার প্রসেস।

আপনি যখন কোনও ওয়েপয়েন্টের লোকেশন হিসেবে কোনও অ্যাড্রেস স্ট্রিং পাস করেন, তখন 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" (প্রযুক্তিগতভাবে "গ্রেট ব্রিটেন ও উত্তর আয়ারল্যান্ডের যুক্তরাজ্য" সত্তার জন্য)।

"টোলেডো" থেকে "মাদ্রিদ" যাওয়ার জন্য দিকনির্দেশ সংক্রান্ত অনুরোধে regionCode প্যারামিটার অন্তর্ভুক্ত থাকলে উপযুক্ত ফলাফল পাওয়া যায় কারণ "টোলেডো" স্পেনের একটি শহর হিসেবে ব্যাখ্যা করা হয়:

const request = {
  origin: 'Toledo',
  destination: 'Madrid',
  region: 'es', // Specify the region code for Spain.
};
    

Plus Code

অনেক লোকের কাছে সুনির্দিষ্ট ঠিকানা নেই, যার ফলে তাদের ডেলিভারি পেতে অসুবিধা হতে পারে। অথবা, যাদের ঠিকানা আছে তারা আরও নির্দিষ্ট লোকেশন, যেমন পিছনের দরজা বা লোডিং ডকে ডেলিভারি নিতে পছন্দ করতে পারেন।

Plus Codes হল এমন লোক বা জায়গার জন্য রাস্তার ঠিকানার মতো, যাদের কোনও প্রকৃত ঠিকানা নেই। রাস্তার নাম ও নম্বর সহ ঠিকানার পরিবর্তে, Plus Codes অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেটের উপর ভিত্তি করে তৈরি হয় এবং সংখ্যা ও অক্ষর হিসেবে দেখানো হয়।

Google Plus Codes ডেভেলপ করেছে যাতে প্রত্যেক ব্যক্তি ও জিনিসকে ঠিকানা সংক্রান্ত সুবিধা দেওয়া যায়। Plus Code হল এনকোড করা লোকেশন রেফারেন্স, যা অক্ষাংশ/দ্রাঘিমাংশ কোঅর্ডিনেট থেকে পাওয়া যায় এবং এটি একটি এলাকাকে বোঝায়: ১/৮০০০ ডিগ্রি বাই ১/৮০০০ ডিগ্রি (নিরক্ষরেখায় প্রায় ১৪ মিটার x ১৪ মিটার) বা তার চেয়ে ছোট। যেসব জায়গায় রাস্তার ঠিকানা নেই বা যেখানে বিল্ডিংয়ের নম্বর বা রাস্তার নাম নেই, সেখানে আপনি রাস্তার ঠিকানার পরিবর্তে Plus Code ব্যবহার করতে পারেন।

Plus Codes অবশ্যই গ্লোবাল কোড বা কম্পাউন্ড কোড হিসেবে ফর্ম্যাট করা থাকতে হবে:

  • গ্লোবাল কোড ৪ অক্ষরের এরিয়া কোড এবং ৬ অক্ষর বা তার বেশি দৈর্ঘ্যের লোকাল কোড দিয়ে তৈরি। যেমন, "1600 Amphitheatre Parkway, Mountain View, CA" ঠিকানার জন্য, গ্লোবাল কোড হল "849V" এবং লোকাল কোড হল "CWC8+R9"। তারপরে, আপনি সম্পূর্ণ ১০টি অক্ষর Plus Code ব্যবহার করে লোকেশন ভ্যালু "849VCWC8+R9" হিসেবে নির্দিষ্ট করেন।
  • কম্পাউন্ড কোড হল ৬টি অক্ষর বা তার চেয়ে বড় স্থানীয় কোড যা স্পষ্ট লোকেশনের সাথে যুক্ত। যেমন, "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'],
};