একটি রুট পান

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

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

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

নিম্নলিখিত কোড নমুনাটি দেখায় কিভাবে দুটি অবস্থানের মধ্যে ড্রাইভিং দিকনির্দেশের জন্য একটি রুট পেতে হয়।

টাইপস্ক্রিপ্ট

// Initialize and add the map.
let map;
let mapPolylines: google.maps.Polyline[] = [];
const center = { lat: 37.447646, lng: -122.113878 }; // Palo Alto, CA

// Initialize and add the map.
async function initMap(): Promise<void> {
  //  Request the needed libraries.
  const [{Map}, {Place}, {Route}] = await Promise.all([
    google.maps.importLibrary('maps') as Promise<google.maps.MapsLibrary>,
    google.maps.importLibrary('places') as Promise<google.maps.PlacesLibrary>,
    //@ts-ignore
    google.maps.importLibrary('routes') as Promise<google.maps.Routes>
  ]);

  map = new Map(document.getElementById("map") as HTMLElement, {
    zoom: 12,
    center: 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'],
  };

  // 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.
  }; 

  // Use lat/lng in a directions request.
  // Mountain View, CA
  const originLatLng = {lat: 37.422000, 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'],
  };

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

  // 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, fallbackInfo, geocodingResults} = await Route.computeRoutes(request);

  // Use createPolylines to create polylines for the route.
  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.setMap(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.
  fitMapToPath(routes[0].path!);
}

// Helper function to fit the map to the path.
async function fitMapToPath(path) {
  const { LatLngBounds } = await google.maps.importLibrary('core') as google.maps.CoreLibrary;
  const bounds = new LatLngBounds();
  path.forEach((point) => {
    bounds.extend(point);
  });
  map.fitBounds(bounds);
}

initMap();

জাভাস্ক্রিপ্ট

// 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 initMap() {
    //  Request the needed libraries.
    const [{ Map }, { Place }, { Route }] = await Promise.all([
        google.maps.importLibrary('maps'),
        google.maps.importLibrary('places'),
        //@ts-ignore
        google.maps.importLibrary('routes')
    ]);
    map = new Map(document.getElementById("map"), {
        zoom: 12,
        center: 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'],
    };
    // 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.
    };
    // Use lat/lng in a directions request.
    // Mountain View, CA
    const originLatLng = { lat: 37.422000, 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'],
    };
    // 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'],
    };
    // 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, fallbackInfo, geocodingResults } = await Route.computeRoutes(request);
    // Use createPolylines to create polylines for the route.
    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.setMap(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.
    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);
}
initMap();

সিএসএস

/*
 * 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>
  <head>
    <title>Get directions</title>

    <link rel="stylesheet" type="text/css" href="./style.css" />
    <script type="module" src="./index.js"></script>
  </head>
  <body>
    <div id="map"></div>
    <!-- prettier-ignore -->
    <script>(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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "beta"});</script>
  </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 সম্পত্তি সেট করে আপনার প্রয়োজনীয় ক্ষেত্রগুলির তালিকা নির্দিষ্ট করুন:

টাইপস্ক্রিপ্ট

// Define a routes request.
const request = {
  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 এ, আপনি নিম্নলিখিত যেকোনো উপায়ে একটি অবস্থান নির্দিষ্ট করতে পারেন:

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

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

  • অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক ব্যবহার করলে অবস্থানটি সেই স্থানাঙ্কগুলির নিকটতম রাস্তায় স্ন্যাপ করা হতে পারে - যা সম্পত্তির অ্যাক্সেস পয়েন্ট নাও হতে পারে, এমনকি এমন কোনও রাস্তাও নাও হতে পারে যা দ্রুত বা নিরাপদে গন্তব্যে নিয়ে যায়।
  • ঠিকানা স্ট্রিংগুলিকে প্রথমে Routes API দ্বারা জিওকোড করতে হবে যাতে কোনও রুট গণনা করার আগে সেগুলিকে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্কে রূপান্তর করা যায়। এই রূপান্তর কর্মক্ষমতাকে প্রভাবিত করতে পারে।

একটি স্থানকে একটি স্থান বস্তু হিসেবে নির্দিষ্ট করুন (পছন্দসই)

একটি Place ব্যবহার করে একটি অবস্থান নির্দিষ্ট করতে, একটি নতুন Place ইনস্ট্যান্স তৈরি করুন। নিম্নলিখিত স্নিপেটে origin এবং destination জন্য নতুন Place ইনস্ট্যান্স তৈরি করা এবং তারপর ComputeRoutesRequest এ সেগুলি ব্যবহার করা দেখানো হয়েছে:

টাইপস্ক্রিপ্ট

// 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.
}; 

জাভাস্ক্রিপ্ট

// 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 এ সেগুলি ব্যবহার করা দেখানো হয়েছে:

টাইপস্ক্রিপ্ট

// Use lat/lng in a directions request.
// Mountain View, CA
const originLatLng = {lat: 37.422000, 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'],
};

জাভাস্ক্রিপ্ট

// Use lat/lng in a directions request.
// Mountain View, CA
const originLatLng = { lat: 37.422000, 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 অ্যাম্ফিথিয়েটার পার্কওয়ে, মাউন্টেন ভিউ, CA")। জিওকোডিং হল একটি ঠিকানা স্ট্রিংকে অক্ষাংশ এবং দ্রাঘিমাংশ স্থানাঙ্কে রূপান্তর করার প্রক্রিয়া (যেমন অক্ষাংশ 37.423021 এবং দ্রাঘিমাংশ -122.083739)।

যখন আপনি একটি ঠিকানা স্ট্রিংকে একটি ওয়েপয়েন্টের অবস্থান হিসেবে পাস করেন, তখন রুটস লাইব্রেরি অভ্যন্তরীণভাবে স্ট্রিংটিকে অক্ষাংশ এবং দ্রাঘিমাংশ স্থানাঙ্কে রূপান্তর করার জন্য জিওকোড করে।

নিচের স্নিপেটে origin এবং destination জন্য একটি ঠিকানা স্ট্রিং সহ একটি ComputeRoutesRequest তৈরি করার পদ্ধতি দেখানো হয়েছে:

টাইপস্ক্রিপ্ট

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

এই উদাহরণে, "টলেডো" কে স্পেনের নয়, মার্কিন যুক্তরাষ্ট্রের ওহিও রাজ্যের একটি শহর হিসেবে ব্যাখ্যা করা হয়েছে। অতএব, অনুরোধটি একটি খালি অ্যারে প্রদান করে, যার অর্থ কোনও রুটের অস্তিত্ব নেই।

আপনি regionCode প্যারামিটার অন্তর্ভুক্ত করে একটি নির্দিষ্ট অঞ্চলে পক্ষপাতদুষ্ট ফলাফল ফেরত দেওয়ার জন্য API কনফিগার করতে পারেন। এই প্যারামিটারটি অঞ্চল কোডটিকে 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.
};
    

প্লাস কোড

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

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

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

প্লাস কোডগুলিকে অবশ্যই একটি গ্লোবাল কোড অথবা একটি যৌগিক কোড হিসেবে ফর্ম্যাট করতে হবে:

  • গ্লোবাল কোড ৪ অক্ষরের একটি এরিয়া কোড এবং ৬ অক্ষর বা তার বেশি স্থানীয় কোড দিয়ে তৈরি। উদাহরণস্বরূপ, "১৬০০ অ্যাম্ফিথিয়েটার পার্কওয়ে, মাউন্টেন ভিউ, ক্যালিফোর্নিয়া" ঠিকানার জন্য, গ্লোবাল কোড হল "৮৪৯V" এবং স্থানীয় কোড হল "CWC8+R9"। এরপর আপনি সমগ্র ১০ অক্ষরের প্লাস কোড ব্যবহার করে অবস্থানের মান "৮৪৯VCWC8+R9" হিসেবে উল্লেখ করতে পারেন।
  • যৌগিক কোডটি ৬ অক্ষর বা তার বেশি স্থানীয় কোডের সমন্বয়ে গঠিত যা একটি স্পষ্ট অবস্থানের সাথে মিলিত হয়। উদাহরণস্বরূপ, "450 Serra Mall, Stanford, CA 94305, USA" ঠিকানাটির স্থানীয় কোড "CRHJ+C3"। একটি যৌগিক ঠিকানার জন্য, "CRHJ+C3 Stanford, CA 94305, USA" ফর্মে ঠিকানার শহর, রাজ্য, জিপ কোড এবং দেশের অংশের সাথে স্থানীয় কোড একত্রিত করুন।

নিম্নলিখিত স্নিপেটে প্লাস কোড ব্যবহার করে রুটের উৎপত্তিস্থল এবং গন্তব্যস্থলের জন্য একটি ওয়েপয়েন্ট নির্দিষ্ট করে একটি রুট গণনা দেখানো হয়েছে:

টাইপস্ক্রিপ্ট

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

জাভাস্ক্রিপ্ট

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