示例#1
0
    /// <summary>
    /// Converts response into an array of results.
    /// </summary>
    /// <param name="response">Response of query.</param>
    /// <returns>Array of result.</returns>
    public static OnlineMapsOSMNominatimResult[] GetResults(string response)
    {
        try
        {
            OnlineMapsXML xml       = OnlineMapsXML.Load(response);
            bool          isReverse = xml.name == "reversegeocode";

            OnlineMapsXMLList resNodes = xml.FindAll(isReverse? "//result" : "//place");
            if (resNodes.count == 0)
            {
                return(null);
            }

            List <OnlineMapsOSMNominatimResult> results = new List <OnlineMapsOSMNominatimResult>();
            foreach (OnlineMapsXML node in resNodes)
            {
                OnlineMapsOSMNominatimResult result = new OnlineMapsOSMNominatimResult(node, isReverse);

                OnlineMapsXML adNode = isReverse ? xml["addressparts"] : node;
                if (!adNode.isNull)
                {
                    result.LoadAddressDetails(adNode);
                }
                results.Add(result);
            }
            return(results.ToArray());
        }
        catch (Exception exception)
        {
            Debug.Log("Can not get a result.\n" + exception.Message + "\n" + exception.StackTrace);
        }

        return(null);
    }
    /// <summary>
    /// Converts response into an array of results.
    /// </summary>
    /// <param name="response">Response of query.</param>
    /// <returns>Array of result.</returns>
    public static OnlineMapsOSMNominatimResult[] GetResults(string response)
    {
        try
        {
            OnlineMapsXML xml = OnlineMapsXML.Load(response);
            bool isReverse = xml.name == "reversegeocode";

            OnlineMapsXMLList resNodes = xml.FindAll(isReverse? "//result" : "//place");
            if (resNodes.count == 0) return null;

            List<OnlineMapsOSMNominatimResult> results = new List<OnlineMapsOSMNominatimResult>();
            foreach (OnlineMapsXML node in resNodes)
            {
                OnlineMapsOSMNominatimResult result = new OnlineMapsOSMNominatimResult(node, isReverse);

                OnlineMapsXML adNode = isReverse ? xml["addressparts"] : node;
                if (!adNode.isNull) result.LoadAddressDetails(adNode);
                results.Add(result);
            }
            return results.ToArray();
        }
        catch (Exception exception)
        {
            Debug.Log(exception.Message + "\n" + exception.StackTrace);
        }

        return null;
    }
示例#3
0
 public override void Init(OnlineMapsOSMNominatimResult _data)
 {
     base.Init(_data);
     xButton.SetActive(true);
     GSHome.Instance.LockPositionClick(data);
     GSHome.Instance.localeCurrent.Init(data);
 }
示例#4
0
 public void Init(OnlineMapsOSMNominatimResult _data)
 {
     data = _data;
     display_name.text = data.display_name;
     position.text     = data.location.ToString();
     Show(true);
 }
示例#5
0
 public void LockPositionClick(OnlineMapsOSMNominatimResult data)
 {
     SetSearchMarker(data.location, data.display_name);
     if (_api.zoom < 13)
     {
         _api.zoom = 13;
     }
     _api.position = data.location;
     _api.Redraw();
 }
示例#6
0
 public void OnUnitClick(OnlineMapsOSMNominatimResult _data)
 {
     Show(false);
     lableCurrent.Init(_data);
 }
示例#7
0
 public virtual void Init(OnlineMapsOSMNominatimResult _data)
 {
     data     = _data;
     txt.text = data.display_name;
 }
示例#8
0
 public void OnUnitClickDirections(OnlineMapsOSMNominatimResult data)
 {
     localeObj.SetActive(false);
     directionsObj.gameObject.SetActive(true);
     ToLocale.Init(data);
 }