Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Avrupa Ekonomik Alanı (AEA) geliştiricileri
Route Optimization API iki yöntem sunar:
OptimizeTours, OptimizeToursRequest yanıtı olarak optimize edilmiş bir rota döndüren eşzamanlı bir yöntemdir. İstemciler, istek işlenene ve OptimizeToursResponse veya hata döndürülene kadar Route Optimization API ile açık bir bağlantı sürdürmelidir.
BatchOptimizeTours, bir veya daha fazla OptimizeToursRequest için URI'leri ve karşılık gelen OptimizeToursResponse mesajlarını kabul eden, toplu işlemin tamamlanıp tamamlanmadığını kontrol etmek için kullanılan bir uzun süreli işlem (LRO) kaynak adını döndüren eşzamansız bir yöntemdir (REST, gRPC). OptimizeToursRequest'ler arka planda işlenir. Bu nedenle, istemciler yalnızca BatchOptimizeToursRequest göndermek veya LRO durumunu kontrol etmek için GetOperation'yu çağırmak üzere yeterli süre boyunca Rota Optimizasyonu API'sine açık bağlantılarını korur. BatchOptimizeTours, Google Cloud Storage'dan gelen istekleri okur ve yanıtları buraya yazar.
Kullanım alanları
OptimizeTours, küçük ve basit istekleri çözmek ya da birkaç dakika veya daha kısa sürede çözülebilecek istekler için uygundur. Rota Optimizasyonu API'si ile uzun süreli bağlantıların sürdürülmesi, çözüm döndürülmeden önce kesinti riskini artırır.
BatchOptimizeTours, Route Optimization API'ye uzun süreli bir bağlantı gerektirmediği için daha büyük ve daha uzun sürede çözülen istekleri işleyebilir.
Uzun süreli işlemler
Toplu işlemin tamamlanma durumunu kontrol etmek için GetOperation yöntemi kullanılarak Rota Optimizasyonu API'sinden uzun süreli işlemler okunur. LRO'lar, toplu işlemin tamamının işlenmesinin tamamlanıp tamamlanmadığını belirten bir done özelliği ve işleme sırasında karşılaşılan hataları bildiren bir error alanı içerir. done doğruysa ve error yoksa toplu işlem başarıyla tamamlanmıştır. error simgesinin bulunması, toplu işlemin bir kısmının veya tamamının işlenemediğini gösterir.
Bir BatchOptimizeTours isteğinin tipik yaşam döngüsü şu şekildedir:
BatchOptimizeToursRequest gönderin. Bu, Route Optimization API'ye gönderilir ve LRO'nun kaynak adını döndürür.
done veya error özellikleri LRO yanıtında görünene kadar döndürülen LRO kaynak adıyla GetOperation anketini yapın.
done doğruysa ve hata yoksa BatchOptimizeTours isteğinde belirtilen Google Cloud Storage URI'lerinden OptimizeToursResponses okunur. error varsa hatayı inceleyin, Google Cloud Storage'daki OptimizeToursRequest'leri buna göre güncelleyin ve gözlemlenen hataya bağlı olarak uygun şekilde yeniden deneyin.
OptimizeTours ve BatchOptimizeTours isteklerini komut satırından veya bir istemci kitaplığı kullanarak çeşitli şekillerde gönderebilirsiniz.
[null,null,["Son güncelleme tarihi: 2025-08-31 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,["# Synchronous and asynchronous endpoints\n\n**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\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-----------------------\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)"]]