রুট পলিলাইন কাস্টমাইজ করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
ভোক্তা ব্যবহারকারী এবং ফ্লিট অপারেটরদের জন্য আপনার ওয়েব-ভিত্তিক যাত্রা ট্র্যাকিং অ্যাপে আপনি যে মানচিত্রে ব্যবহার করেন তার জন্য রুট পলিলাইনগুলি কীভাবে কাস্টমাইজ করবেন তা এই দস্তাবেজটি কভার করে।
কনজিউমার SDK-এর সাহায্যে, আপনি রুট পলিলাইন দৃশ্যমানতা নিয়ন্ত্রণ করতে পারেন বা মানচিত্রে যাত্রার রুটের জন্য রুট পলিলাইন স্টাইল করতে পারেন। SDK যাত্রার সক্রিয় বা অবশিষ্ট পথের প্রতিটি জোড়া স্থানাঙ্কের জন্য একটি google.maps.Polyline
অবজেক্ট তৈরি করে৷ লাইব্রেরি তারপর দুটি পরিস্থিতিতে এই কাস্টমাইজেশন প্রয়োগ করে:
- মানচিত্রে বস্তু যোগ করার আগে
- যখন বস্তুর জন্য ব্যবহৃত ডেটা পরিবর্তিত হয়
শৈলী রুট পলিলাইন
আপনি যেভাবে মার্কারকে স্টাইল করতে পারেন তার অনুরূপ, আপনি কাস্টমাইজেশন প্যারামিটার ব্যবহার করে পলিলাইন রুট করেন। সেখান থেকে, আপনি নিম্নলিখিত পদ্ধতির একটি ব্যবহার করে স্টাইলিং কনফিগার করেন:
- সহজতম :
PolylineOptions
ব্যবহার করুন সমস্ত মিলে যাওয়া Polyline
অবজেক্টে প্রয়োগ করার জন্য যখন সেগুলি তৈরি বা আপডেট করা হয়। - উন্নত : একটি কাস্টমাইজেশন ফাংশন নির্দিষ্ট করুন। কাস্টমাইজেশন ফাংশনগুলি ফ্লিট ইঞ্জিন দ্বারা প্রেরিত ডেটার উপর ভিত্তি করে বস্তুর পৃথক স্টাইল করার অনুমতি দেয়। যাত্রার বর্তমান অবস্থার উপর ভিত্তি করে ফাংশনটি প্রতিটি বস্তুর স্টাইলিং পরিবর্তন করতে পারে; উদাহরণস্বরূপ,
Polyline
বস্তুটিকে একটি গভীর ছায়ায় রঙ করা, বা গাড়িটি ধীর গতিতে চলার সময় এটিকে ঘন করা। এমনকি আপনি ফ্লিট ইঞ্জিনের বাইরের উত্স থেকেও যোগ দিতে পারেন এবং সেই তথ্যের ভিত্তিতে Polyline
অবজেক্টকে স্টাইল করতে পারেন।
কাস্টমাইজেশন পরামিতি
রুট পলিলাইন স্টাইল করার সময়, আপনি FleetEngineShipmentLocationProviderOptions
এ দেওয়া প্যারামিটার ব্যবহার করেন। এই পরামিতিগুলি গাড়ির যাত্রায় বিভিন্ন পাথ স্টেটের জন্য প্রদান করে, নিম্নরূপ:
PolylineOptions
ব্যবহার করুন
নিম্নোক্ত উদাহরণ দেখায় কিভাবে PolylineOptions
সাথে Polyline
অবজেক্টের জন্য স্টাইলিং কনফিগার করতে হয়। পূর্বে তালিকাভুক্ত যেকোনো পলিলাইন কাস্টমাইজেশন ব্যবহার করে যেকোনো Polyline
অবজেক্টের স্টাইলিং কাস্টমাইজ করতে এই প্যাটার্নটি অনুসরণ করুন।
জাভাস্ক্রিপ্ট
activePolylineCustomization = {
strokeWidth: 5,
strokeColor: 'black',
};
টাইপস্ক্রিপ্ট
activePolylineCustomization = {
strokeWidth: 5,
strokeColor: 'black',
};
রুট পলিলাইন স্টাইল করতে কাস্টমাইজেশন ফাংশন ব্যবহার করুন
নিম্নলিখিত উদাহরণ দেখায় কিভাবে একটি সক্রিয় রুট পলিলাইনের জন্য স্টাইলিং কনফিগার করতে হয়। পূর্বে তালিকাভুক্ত যে কোনো রুট পলিলাইন কাস্টমাইজেশন প্যারামিটার ব্যবহার করে যেকোনো Polyline
অবজেক্টের স্টাইলিং কাস্টমাইজ করতে এই প্যাটার্নটি অনুসরণ করুন।
জাভাস্ক্রিপ্ট
// Color the route polyline objects in green if the vehicle is nearby.
activePolylineCustomization =
(params) => {
const distance = params.taskTrackingInfo.remainingDrivingDistanceMeters;
if (distance < 1000) {
// params.polylines contains an ordered list of Polyline objects for
// the path.
for (const polylineObject of params.polylines) {
polylineObject.setOptions({strokeColor: 'green'});
}
}
};
টাইপস্ক্রিপ্ট
// Color the route Polyline objects in green if the vehicle is nearby.
activePolylineCustomization =
(params: ShipmentPolylineCustomizationFunctionParams) => {
const distance = params.taskTrackingInfo.remainingDrivingDistanceMeters;
if (distance < 1000) {
// params.polylines contains an ordered list of Polyline objects for
// the path.
for (const polylineObject of params.polylines) {
polylineObject.setOptions({strokeColor: 'green'});
}
}
};
রুট পলিলাইন দৃশ্যমানতা নিয়ন্ত্রণ করুন
ডিফল্টরূপে, সমস্ত Polyline
বস্তু দৃশ্যমান। একটি Polyline
বস্তুকে অদৃশ্য করতে, এর visible
সম্পত্তি সেট করুন:
জাভাস্ক্রিপ্ট
remainingPolylineCustomization = {visible: false};
টাইপস্ক্রিপ্ট
remainingPolylineCustomization = {visible: false};
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-09-03 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-09-03 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis guide explains how to customize the appearance and visibility of route polylines within your web-based journey tracking applications using the Consumer SDK.\u003c/p\u003e\n"],["\u003cp\u003eYou can style route polylines by either using \u003ccode\u003ePolylineOptions\u003c/code\u003e for simple styling across all polylines or by employing customization functions for advanced, data-driven styling of individual polyline segments.\u003c/p\u003e\n"],["\u003cp\u003eCustomization parameters allow you to control the styling of already traveled, actively traveled, and not-yet traveled paths independently.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to apply these customization techniques using both \u003ccode\u003ePolylineOptions\u003c/code\u003e and customization functions in JavaScript and TypeScript.\u003c/p\u003e\n"],["\u003cp\u003eRoute polyline visibility can be easily toggled by setting the \u003ccode\u003evisible\u003c/code\u003e property to \u003ccode\u003efalse\u003c/code\u003e within the desired customization parameters.\u003c/p\u003e\n"]]],["This document details customizing route polylines in a web-based journey tracking app using the Consumer SDK. Styling is achieved via `PolylineOptions` for simple application to all `Polyline` objects or through customization functions for dynamic styling based on journey data. Customization parameters include styling for already traveled, actively traveled, and not-yet-traveled paths. Visibility can be controlled by setting the `visible` property. Customization functions allow altering `Polyline` objects' styles based on real-time journey data, such as changing colors based on distance.\n"],null,["\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis document covers how to customize route polylines for the map you use in\nyour web-based journey tracking app for consumer users and fleet operators.\n\nWith the Consumer SDK, you can control route polyline visibility or style the\nroute polyline for a journey's route on the map. The SDK creates a\n[`google.maps.Polyline`](/maps/documentation/javascript/reference/polygon#Polyline) object for each pair of coordinates in the journey's\nactive or remaining path. The library then applies these customizations in\ntwo situations:\n\n- before adding the objects to the map\n- when the data used for the objects have changed\n\nStyle route polylines\n\nSimilar to how you can style markers, you style route polylines using\n**customization parameters**. From there, you configure styling using one of the\nfollowing approaches:\n\n- **Simplest** : Use `PolylineOptions` to apply to all of the matched `Polyline` objects when they are created or updated.\n- **Advanced** : Specify a **customization function** . Customization functions allow for individual styling of the objects based on data sent by Fleet Engine. The function can change the styling of each object based on the current state of the journey; for example, coloring the `Polyline` object a deeper shade, or making it thicker when the vehicle is moving slower. You can even join against from sources outside Fleet Engine and style the `Polyline` object based on that information.\n\nCustomization parameters\n\nWhen styling route polylines, you use parameters provided in\n[`FleetEngineShipmentLocationProviderOptions`](/maps/documentation/javascript/reference/journey-sharing-shipment-tracking#FleetEngineShipmentLocationProviderOptions). These parameters provide for\ndifferent path states in the vehicle's journey, as follows:\n\n- **Already traveled** paths: Use [`takenPolylineCustomization`](/maps/documentation/javascript/reference/journey-sharing-shipment-tracking#FleetEngineShipmentLocationProviderOptions.takenPolylineCustomization).\n- **Actively traveled** path: Use [`activePolylineCustomization`](/maps/documentation/javascript/reference/journey-sharing-shipment-tracking#FleetEngineShipmentLocationProviderOptions.activePolylineCustomization).\n- **Not-yet traveled** path: Use [`remainingPolylineCustomization`](/maps/documentation/javascript/reference/journey-sharing-shipment-tracking#FleetEngineShipmentLocationProviderOptions.remainingPolylineCustomization).\n\nUse `PolylineOptions`\n\nThe following example shows how to configure the styling for a `Polyline` object\nwith [`PolylineOptions`](/maps/documentation/javascript/reference/polygon#PolylineOptions). Follow this pattern to customize the styling of\nany `Polyline` object using any of the polyline customizations listed earlier.\n\n\u003cbr /\u003e\n\nJavaScript\n\n\u003cbr /\u003e\n\n activePolylineCustomization = {\n strokeWidth: 5,\n strokeColor: 'black',\n };\n\n\u003cbr /\u003e\n\nTypeScript\n\n\u003cbr /\u003e\n\n activePolylineCustomization = {\n strokeWidth: 5,\n strokeColor: 'black',\n };\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nUse customization functions to style route polylines\n\nThe following example shows how to configure styling for an active route\npolyline. Follow this pattern to customize the styling of any `Polyline` object\nusing any of the route polyline customization parameters listed earlier.\n\n\u003cbr /\u003e\n\nJavaScript\n\n\u003cbr /\u003e\n\n // Color the route polyline objects in green if the vehicle is nearby.\n activePolylineCustomization =\n (params) =\u003e {\n const distance = params.taskTrackingInfo.remainingDrivingDistanceMeters;\n if (distance \u003c 1000) {\n\n // params.polylines contains an ordered list of Polyline objects for\n // the path.\n for (const polylineObject of params.polylines) {\n polylineObject.setOptions({strokeColor: 'green'});\n }\n }\n };\n\n\u003cbr /\u003e\n\nTypeScript\n\n\u003cbr /\u003e\n\n // Color the route Polyline objects in green if the vehicle is nearby.\n activePolylineCustomization =\n (params: ShipmentPolylineCustomizationFunctionParams) =\u003e {\n const distance = params.taskTrackingInfo.remainingDrivingDistanceMeters;\n if (distance \u003c 1000) {\n\n // params.polylines contains an ordered list of Polyline objects for\n // the path.\n for (const polylineObject of params.polylines) {\n polylineObject.setOptions({strokeColor: 'green'});\n }\n }\n };\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nControl route polyline visibility\n\nBy default, all `Polyline` objects are visible. To make a `Polyline` object\ninvisible, set its [`visible`](/maps/documentation/javascript/reference/polygon#PolylineOptions) property:\n\n\u003cbr /\u003e\n\nJavaScript\n\n\u003cbr /\u003e\n\n remainingPolylineCustomization = {visible: false};\n\n\u003cbr /\u003e\n\nTypeScript\n\n\u003cbr /\u003e\n\n remainingPolylineCustomization = {visible: false};\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]