1 (edited by mikli1 2023-12-27 12:28:54)

Topic: openrouteservices autocomplete

How can I use openrouteservices for address autocomplete? I need a open route service version of OnlineMapsGooglePlacesAutocomplete and OnlineMapsGooglePlacesAutocompleteResult right?

There are examples from OpenRouteService for Directions and Geocoding. Can I use geocoding as the autocomplete functionality

Thanks for help

Re: openrouteservices autocomplete

Hello.

Previously, ORS did not have an API for autocomplete.
I just checked the documentation and now ORS has an autocomplete API (experimental).
Unfortunately Online Maps can't work with it directly, but that doesn't mean you can't use it.
Just make the request and process the response yourself.
Example:

using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class ORSAutocomplete : MonoBehaviour
    {
        public string key;
    
        private void Start()
        {
            OnlineMapsWWW www = new OnlineMapsWWW($"https://api.openrouteservice.org/geocode/autocomplete?api_key={key}&text=Toky");
            www.OnComplete += OnRequestComplete;
        }

        private void OnRequestComplete(OnlineMapsWWW www)
        {
            OnlineMapsJSONItem json = OnlineMapsJSON.Parse(www.text);
            foreach (OnlineMapsJSONItem item in json["features"])
            {
                Debug.Log(item["properties/label"].V<string>());
            }
        }
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.