Tetap teratur dengan koleksi Simpan dan kategorikan konten berdasarkan preferensi Anda.
Developer Wilayah Ekonomi Eropa (EEA)
Route Optimization API mengekspos dua metode:
OptimizeTours adalah metode sinkron yang menampilkan rute yang dioptimalkan sebagai respons terhadap OptimizeToursRequest. Klien harus mempertahankan koneksi terbuka ke Route Optimization API hingga permintaan diproses dan OptimizeToursResponse atau error ditampilkan.
BatchOptimizeTours adalah metode asinkron yang menerima URI untuk satu atau beberapa pesan OptimizeToursRequest dan OptimizeToursResponse yang sesuai, yang menampilkan nama resource Operasi yang Berjalan Lama (LRO) (REST, gRPC) yang digunakan untuk memeriksa penyelesaian batch. OptimizeToursRequest diproses di latar belakang, sehingga klien mempertahankan koneksi terbuka ke Route Optimization API hanya cukup lama untuk mengirimkan BatchOptimizeToursRequest atau memanggil GetOperation untuk memeriksa status LRO. BatchOptimizeTours membaca permintaan dari dan menulis respons ke Google Cloud Storage.
Kasus penggunaan
OptimizeTours cocok untuk menyelesaikan permintaan kecil dan sederhana, atau untuk permintaan dengan waktu penyelesaian beberapa menit atau kurang. Mempertahankan koneksi persisten ke Route Optimization API meningkatkan risiko gangguan sebelum solusi dapat ditampilkan.
BatchOptimizeTours dapat menangani permintaan yang lebih besar dan permintaan dengan waktu penyelesaian yang lebih lama karena tidak memerlukan koneksi yang berjalan lama ke Route Optimization API.
Operasi yang berjalan lama
LRO dibaca dari Route Optimization API menggunakan metode GetOperation untuk memeriksa status penyelesaian batch. LRO mencakup properti done yang menunjukkan apakah pemrosesan seluruh batch telah selesai dan kolom error yang melaporkan error yang terjadi selama pemrosesan. Jika done bernilai benar dan tidak ada error, batch berhasil diselesaikan. Adanya error menunjukkan bahwa sebagian atau semua batch gagal diproses.
Siklus proses umum permintaan BatchOptimizeTours adalah sebagai berikut:
Kirimkan BatchOptimizeToursRequest ke Route Optimization API, yang menampilkan nama resource LRO.
Polling GetOperation dengan nama resource LRO yang ditampilkan hingga properti done atau error muncul dalam respons LRO.
Jika done bernilai benar (true) dan tidak ada error, baca OptimizeToursResponses dari URI Google Cloud Storage yang ditentukan dalam permintaan BatchOptimizeTours. Jika error ada, periksa error, perbarui OptimizeToursRequest yang sesuai di Google Cloud Storage, dan coba lagi sesuai dengan error yang diamati.
Anda dapat mengirim permintaan OptimizeTours dan BatchOptimizeTours dengan berbagai cara, baik dari command line maupun menggunakan library klien.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-10 UTC."],[[["\u003cp\u003eThe Route Optimization API offers two methods: \u003ccode\u003eOptimizeTours\u003c/code\u003e for synchronous processing of smaller, simpler requests and \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e for asynchronous handling of larger, more complex requests.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeTours\u003c/code\u003e requires an open connection until a response is received, while \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e utilizes Google Cloud Storage for requests and responses, enabling background processing.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBatchOptimizeTours\u003c/code\u003e relies on Long Running Operations (LROs) to track batch progress, which can be monitored via the \u003ccode\u003eGetOperation\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eWhen using \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e, users should submit the request, poll for completion using the LRO, and retrieve results or address errors as indicated by the LRO status.\u003c/p\u003e\n"]]],[],null,["**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nThe Route Optimization API exposes two methods:\n\n- `OptimizeTours` is a *synchronous* method that returns an optimized route in response to an `OptimizeToursRequest`. Clients must maintain an open connection to the Route Optimization API until the request is processed and an `OptimizeToursResponse` or error is returned.\n- `BatchOptimizeTours` is an *asynchronous* method that accepts URIs for one or more `OptimizeToursRequest` and corresponding `OptimizeToursResponse` messages, returning the resource name of a *Long Running Operation* (LRO) ([REST](/maps/documentation/route-optimization/reference/rest/v1/projects.locations.operations#Operation), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.longrunning#google.longrunning.Operations))) that is used to check for batch completion. `OptimizeToursRequest`s are processed in the background, so clients maintain an open connections to the Route Optimization API only long enough to submit the `BatchOptimizeToursRequest` or to call `GetOperation` to check LRO status. `BatchOptimizeTours` reads requests from and writes responses to [Google Cloud Storage](https://cloud.google.com/storage).\n\nUse cases\n\n`OptimizeTours` is convenient for solving small and simple requests, or for\nrequests with solving times of a few minutes or less. Maintaining long-lived\nconnections to the Route Optimization API increases risk of interruption before\na solution can be returned.\n\n`BatchOptimizeTours` can handle larger requests and requests with longer solving\ntime because it does not require a long-lived connection to the Route\nOptimization API.\n\nLong running operations\n\nLROs are read from the Route Optimization API using the `GetOperation` method to\ncheck the completion status of a batch. LROs include a `done` property that\nindicates whether processing of the entire batch is complete and an `error`\nfield that reports errors encountered during processing. If `done` is true and\nno `error` is present, the batch completed successfully. The presence of an\n`error` indicates that some or all of the batch failed processing.\n| **Note:** REST `GetOperation` responses omit the `done` property if its value is false and the `error` property if no errors occurred.\n\nThe typical lifecycle of a `BatchOptimizeTours` request is as follows:\n\n1. Submit a `BatchOptimizeToursRequest` to the Route Optimization API, which returns the resource name of an LRO.\n2. Poll `GetOperation` with the returned LRO resource name until the `done` or `error` properties appear in the LRO response.\n3. If `done` is true and no error is present, read `OptimizeToursResponses` from the Google Cloud Storage URIs specified in the `BatchOptimizeTours` request. If `error` is present, inspect the error, update the `OptimizeToursRequest`s accordingly in Google Cloud Storage, and retry as appropriate depending on the observed error.\n\nYou can send `OptimizeTours` and `BatchOptimizeTours` requests in a variety of\nways, either from the command line or using a client library.\n\n[Next: Make an API Request](/maps/documentation/route-optimization/make-request)"]]